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
35a89f7e
Commit
35a89f7e
authored
Nov 23, 2016
by
d4vidi
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Posting and clearing
parent
07664a60
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
31 additions
and
0 deletions
+31
-0
android/src/main/java/com/wix/reactnativenotifications/core/RNNotificationsModule.java
.../reactnativenotifications/core/RNNotificationsModule.java
+24
-0
android/src/main/java/com/wix/reactnativenotifications/core/notificationdrawer/IPushNotificationsDrawer.java
...ons/core/notificationdrawer/IPushNotificationsDrawer.java
+1
-0
android/src/main/java/com/wix/reactnativenotifications/core/notificationdrawer/PushNotificationsDrawer.java
...ions/core/notificationdrawer/PushNotificationsDrawer.java
+6
-0
No files found.
android/src/main/java/com/wix/reactnativenotifications/core/RNNotificationsModule.java
View file @
35a89f7e
...
...
@@ -12,6 +12,9 @@ import com.facebook.react.bridge.Promise;
import
com.facebook.react.bridge.ReactApplicationContext
;
import
com.facebook.react.bridge.ReactContextBaseJavaModule
;
import
com.facebook.react.bridge.ReactMethod
;
import
com.facebook.react.bridge.ReadableMap
;
import
com.wix.reactnativenotifications.core.notification.IPushNotification
;
import
com.wix.reactnativenotifications.core.notification.PushNotification
;
import
com.wix.reactnativenotifications.core.notification.PushNotificationProps
;
import
com.wix.reactnativenotifications.core.notificationdrawer.IPushNotificationsDrawer
;
import
com.wix.reactnativenotifications.core.notificationdrawer.PushNotificationsDrawer
;
...
...
@@ -66,6 +69,27 @@ public class RNNotificationsModule extends ReactContextBaseJavaModule implements
}
}
@ReactMethod
public
void
postLocalNotification
(
ReadableMap
notificationPropsMap
,
final
Promise
promise
)
{
Log
.
d
(
LOGTAG
,
"Native method invocation: postLocalNotification"
);
Object
result
=
null
;
try
{
final
Bundle
notificationProps
=
Arguments
.
toBundle
(
notificationPropsMap
);
final
IPushNotification
pushNotification
=
PushNotification
.
get
(
getReactApplicationContext
().
getApplicationContext
(),
notificationProps
,
ReactAppLifecycleFacade
.
get
());
int
id
=
pushNotification
.
onPostRequest
();
result
=
id
;
}
finally
{
promise
.
resolve
(
result
);
}
}
@ReactMethod
public
void
removeLocalNotification
(
int
notificationId
)
{
IPushNotificationsDrawer
notificationsDrawer
=
PushNotificationsDrawer
.
get
(
getReactApplicationContext
().
getApplicationContext
());
notificationsDrawer
.
onNotificationClear
(
notificationId
);
}
@Override
public
void
onAppVisible
()
{
final
IPushNotificationsDrawer
notificationsDrawer
=
PushNotificationsDrawer
.
get
(
getReactApplicationContext
().
getApplicationContext
());
...
...
android/src/main/java/com/wix/reactnativenotifications/core/notificationdrawer/IPushNotificationsDrawer.java
View file @
35a89f7e
...
...
@@ -8,4 +8,5 @@ public interface IPushNotificationsDrawer {
void
onNewActivity
(
Activity
activity
);
void
onNotificationOpened
();
void
onNotificationClear
(
int
id
);
}
android/src/main/java/com/wix/reactnativenotifications/core/notificationdrawer/PushNotificationsDrawer.java
View file @
35a89f7e
...
...
@@ -47,6 +47,12 @@ public class PushNotificationsDrawer implements IPushNotificationsDrawer {
clearAll
();
}
@Override
public
void
onNotificationClear
(
int
id
)
{
final
NotificationManager
notificationManager
=
(
NotificationManager
)
mContext
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
notificationManager
.
cancel
(
id
);
}
protected
void
clearAll
()
{
final
NotificationManager
notificationManager
=
(
NotificationManager
)
mContext
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
notificationManager
.
cancelAll
();
...
...
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