Open windydang26 opened 6 years ago
FCM.removeDeliveredNotification(id) not working for me
FCM.removeAllDeliveredNotifications
I have been trying all function of FCM (cancel, cancelAll, remove, removeAll) but not working. If i using them immediate willPresent not working, but when i use them at other moment it working.
can you elaborate the scenario? you want to receive the notification, show the banner and clear it from try right away?
Thank @evollu, I mean is if i am staying current screen and have notify of current screen i just want show banner now, but i don't want notify exist in notifications center. Can u help me?
case NotificationType.WillPresent:
FCM.cancelAllLocalNotifications();
FCM.removeDeliveredNotification(notif.id);
FCM.cancelLocalNotification(notif.id);
my code not working
@windydang26 try add a timeout of 2 seconds? notification hasn't been created at that time point.
BTW FCM.cancelAllLocalNotifications();
removes recurring/delayed notification schedule, which is not related to your use case
I am using this both but not working
componentWillMount(){
FCM.removeDeliveredNotification()
FCM.cancelAllLocalNotifications()
console.log("Setp_Details_CompountWillMount_Called here")
}
i want to stop notf. only in one screen what should i do for that
@evollu Sorry, resurrecting old issue so that we don't have too many open ones.
I can't seem to be able to remove a single notification with FCM.removeDeliveredNotification(notifId).
FCM.removeAllDeliveredNotifications() works fine, though.
To give you some more info, here's the snippet I'm using to test the removal :
handleNotification(notif) {
console.log(' - New notification received: ');
console.log(JSON.stringify(notif, null, 2));
console.log('---------------------------------------------');
sleep(30000).then( () => {
console.log(' ----- removing all delivered notifications')
FCM.removeDeliveredNotification("mynotif")
})
…
}
(sleep
is a simple arrow function which takes a delay in milliseconds and fires a promise after that delay, so I expect the notification to sit in the notification center for 30 secs and then be removed)
The app is obviously open or in background, otherwise the notification handler and thus the sleep promise wouldn't be fired.
The notification payload is :
{
"message": {
"token" : "fy...V7k",
"apns" : {
"headers" : {
"apns-priority" : "5",
"apns-collapse-id" : "myapnsid",
},
},
"android" : {
"priority" : "normal",
"notification": {
"tag" : "myandroidtag",
}
},
"data" : {
"id" : "mynotif",
},
"notification" : {
"title" : "Test notif",
"body" : "Test notif body 999",
}
}
}
Note, I'm using FCM v1 API and thus payload, since I can't seem to be able to have the collapsing (via apns-collapse-id under iOS, tag under Android) work otherwise.
Everything is working fine, collapsing, silent notifications, everything, but I can't find a way to remove a single, particular notification. It looks like removeDeliveredNotification can't match the delivered notifications to the passed notificationId...
when user using app. if notify arrive i have been show local notification but then i dont want this noti show in list notification (swipe down from statusbar) any solution?