Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
react-native-notifications
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Jira
Jira
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
冷佳娟
react-native-notifications
Commits
7f1845d0
Commit
7f1845d0
authored
Aug 22, 2017
by
Guy Carmeli
Committed by
GitHub
Aug 22, 2017
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #111 from wix/android_permission_check
Added support for checking permissions on android
parents
26da9c9a
77840081
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
0 deletions
+23
-0
android/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java
...m/wix/reactnativenotifications/RNNotificationsModule.java
+7
-0
example/index.android.js
example/index.android.js
+12
-0
index.android.js
index.android.js
+4
-0
No files found.
android/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java
View file @
7f1845d0
...
...
@@ -5,6 +5,7 @@ import android.app.Application;
import
android.content.Context
;
import
android.content.Intent
;
import
android.os.Bundle
;
import
android.support.v4.app.NotificationManagerCompat
;
import
android.util.Log
;
import
com.facebook.react.bridge.Arguments
;
...
...
@@ -89,6 +90,12 @@ public class RNNotificationsModule extends ReactContextBaseJavaModule implements
notificationsDrawer
.
onNotificationClearRequest
(
notificationId
);
}
@ReactMethod
public
void
isRegisteredForRemoteNotifications
(
Promise
promise
)
{
boolean
hasPermission
=
NotificationManagerCompat
.
from
(
getReactApplicationContext
()).
areNotificationsEnabled
();
promise
.
resolve
(
new
Boolean
(
hasPermission
));
}
@Override
public
void
onAppVisible
()
{
final
IPushNotificationsDrawer
notificationsDrawer
=
PushNotificationsDrawer
.
get
(
getReactApplicationContext
().
getApplicationContext
());
...
...
example/index.android.js
View file @
7f1845d0
...
...
@@ -126,10 +126,22 @@ class MainComponent extends Component {
<
TouchableHighlight
onPress
=
{()
=>
this
.
onCancelNotification
()}
>
<
Text
style
=
{
styles
.
plainButtonText
}
>
Undo
last
<
/Text
>
<
/TouchableHighlight
>
<
TouchableHighlight
onPress
=
{()
=>
this
.
onCheckPermissions
()}
>
<
Text
style
=
{
styles
.
plainButtonText
}
>
Check
permissions
<
/Text
>
<
/TouchableHighlight
>
<
/View
>
)
}
async
onCheckPermissions
()
{
const
hasPermissions
=
await
NotificationsAndroid
.
isRegisteredForRemoteNotifications
();
if
(
hasPermissions
)
{
alert
(
'
Yay! You have permissions
'
);
}
else
{
alert
(
'
Boo! You don
\'
t have permissions
'
);
}
}
onPushRegistered
()
{
}
...
...
index.android.js
View file @
7f1845d0
...
...
@@ -41,6 +41,10 @@ export class NotificationsAndroid {
}
}
static
async
isRegisteredForRemoteNotifications
()
{
return
await
RNNotifications
.
isRegisteredForRemoteNotifications
();
}
static
refreshToken
()
{
RNNotifications
.
refreshToken
();
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment