Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
R
react-native-fcm
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
ym
react-native-fcm
Commits
669d2630
Commit
669d2630
authored
Dec 05, 2016
by
Libin Lu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
removeDeliveredNotifications
parent
d60b36d5
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
51 additions
and
14 deletions
+51
-14
android/src/main/java/com/evollu/react/fcm/FIRLocalMessagingHelper.java
...in/java/com/evollu/react/fcm/FIRLocalMessagingHelper.java
+10
-11
android/src/main/java/com/evollu/react/fcm/FIRMessagingModule.java
...rc/main/java/com/evollu/react/fcm/FIRMessagingModule.java
+10
-0
index.js
index.js
+15
-1
ios/RNFIRMesssaging.m
ios/RNFIRMesssaging.m
+16
-2
No files found.
android/src/main/java/com/evollu/react/fcm/FIRLocalMessagingHelper.java
View file @
669d2630
...
...
@@ -253,24 +253,13 @@ public class FIRLocalMessagingHelper {
}
public
void
cancelLocalNotification
(
String
notificationId
)
{
NotificationManager
notificationManager
=
(
NotificationManager
)
mContext
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
notificationManager
.
cancel
(
notificationId
.
hashCode
());
cancelAlarm
(
notificationId
);
SharedPreferences
.
Editor
editor
=
sharedPreferences
.
edit
();
editor
.
remove
(
notificationId
);
editor
.
apply
();
}
public
void
cancelAllLocalNotifications
()
{
NotificationManager
notificationManager
=
(
NotificationManager
)
mContext
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
notificationManager
.
cancelAll
();
java
.
util
.
Map
<
String
,
?>
keyMap
=
sharedPreferences
.
getAll
();
SharedPreferences
.
Editor
editor
=
sharedPreferences
.
edit
();
for
(
java
.
util
.
Map
.
Entry
<
String
,
?>
entry:
keyMap
.
entrySet
()){
...
...
@@ -280,6 +269,16 @@ public class FIRLocalMessagingHelper {
editor
.
apply
();
}
public
void
removeDeliveredNotification
(
String
notificationId
){
NotificationManager
notificationManager
=
(
NotificationManager
)
mContext
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
notificationManager
.
cancel
(
notificationId
.
hashCode
());
}
public
void
removeAllDeliveredNotifications
(){
NotificationManager
notificationManager
=
(
NotificationManager
)
mContext
.
getSystemService
(
Context
.
NOTIFICATION_SERVICE
);
notificationManager
.
cancelAll
();
}
public
void
cancelAlarm
(
String
notificationId
)
{
Intent
notificationIntent
=
new
Intent
(
mContext
,
FIRLocalMessagingPublisher
.
class
);
PendingIntent
pendingIntent
=
PendingIntent
.
getBroadcast
(
mContext
,
notificationId
.
hashCode
(),
notificationIntent
,
PendingIntent
.
FLAG_UPDATE_CURRENT
);
...
...
android/src/main/java/com/evollu/react/fcm/FIRMessagingModule.java
View file @
669d2630
...
...
@@ -95,6 +95,16 @@ public class FIRMessagingModule extends ReactContextBaseJavaModule implements Li
mFIRLocalMessagingHelper
.
cancelAllLocalNotifications
();
}
@ReactMethod
public
void
removeDeliveredNotification
(
String
notificationID
)
{
mFIRLocalMessagingHelper
.
removeDeliveredNotification
(
notificationID
);
}
@ReactMethod
public
void
removeAllDeliveredNotifications
(){
mFIRLocalMessagingHelper
.
removeAllDeliveredNotifications
();
}
@ReactMethod
public
void
subscribeToTopic
(
String
topic
){
FirebaseMessaging
.
getInstance
().
subscribeToTopic
(
topic
);
...
...
index.js
View file @
669d2630
...
...
@@ -39,13 +39,27 @@ FCM.getScheduledLocalNotifications = function() {
};
FCM
.
cancelLocalNotification
=
(
notificationID
)
=>
{
RNFIRMessaging
.
cancelLocalNotification
(
notificationID
);
if
(
!
notificationID
){
return
;
}
RNFIRMessaging
.
cancelLocalNotification
(
notificationID
);
};
FCM
.
cancelAllLocalNotifications
=
()
=>
{
RNFIRMessaging
.
cancelAllLocalNotifications
();
};
FCM
.
removeDeliveredNotification
=
(
notificationID
)
=>
{
if
(
!
notificationID
){
return
;
}
RNFIRMessaging
.
removeDeliveredNotification
(
notificationID
);
}
FCM
.
removeAllDeliveredNotifications
=
()
=>
{
RNFIRMessaging
.
removeAllDeliveredNotifications
();
}
FCM
.
setBadgeNumber
=
(
number
)
=>
{
RNFIRMessaging
.
setBadgeNumber
(
number
);
}
...
...
ios/RNFIRMesssaging.m
View file @
669d2630
...
...
@@ -276,13 +276,27 @@ RCT_EXPORT_METHOD(scheduleLocalNotification:(id)data resolver:(RCTPromiseResolve
}
}
RCT_EXPORT_METHOD
(
removeDeliveredNotifications
:
(
NSString
*
)
notificationId
)
{
if
([
UNUserNotificationCenter
currentNotificationCenter
]
!=
nil
){
[[
UNUserNotificationCenter
currentNotificationCenter
]
removeDeliveredNotificationsWithIdentifiers
:@[
notificationId
]];
}
}
RCT_EXPORT_METHOD
(
removeAllDeliveredNotifications
)
{
if
([
UNUserNotificationCenter
currentNotificationCenter
]
!=
nil
){
[[
UNUserNotificationCenter
currentNotificationCenter
]
removeAllDeliveredNotifications
];
}
else
{
[
RCTSharedApplication
()
setApplicationIconBadgeNumber
:
0
];
}
}
RCT_EXPORT_METHOD
(
cancelAllLocalNotifications
)
{
if
([
UNUserNotificationCenter
currentNotificationCenter
]
!=
nil
){
[[
UNUserNotificationCenter
currentNotificationCenter
]
removeAllPendingNotificationRequests
];
[[
UNUserNotificationCenter
currentNotificationCenter
]
removeAllDeliveredNotifications
];
}
else
{
[[
UIApplication
sharedApplication
]
setApplicationIconBadgeNumber
:
0
];
[
RCTSharedApplication
()
cancelAllLocalNotifications
];
}
}
...
...
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