Android: Remove notifications from 'notification center'
According to the documentation 'cancelLocalNotifications' is supposed to remove notifications from the 'notification center' in additiion to remove scheduled notifications by id. However, the dismissing of notifications does not seem to workinging on Android.
@varungupta85 we had this working a while back didn't we?
@npomfret I have been using my own fork for the repo for some time as I have been having some problems with some of the commits and I didn't really need those features. But to answer your question, yes this has been working in the past and still works on my fork and I don't think that part of the code has changed, so it should be working now. There may be some problems with the way the API is invoked by @JonesN7 . @JonesN7, please keep in mind that you need to provide an object of shape {id: <notificationId>} to cancel a local notification by id and it will only cancel that notification. If you want to cancel all notifications, then you can use cancelAllLocalNotifications API. Please share your code if you are still having problems.
Just to make sure we are on the same page; I am able to cancel scheduled local notifications by their ID, using cancalLocalNotifications. What this does not do for me, is remove a delivered notification from the status bar. So I can cancel future notification, but not remove delivered ones from the status bar, which from what I understand is the same as the 'notification centre' on iOS, but maybe I am misusing that term.
@JonesN7 This is the line of code that should be called when a specific notification is canceled.
https://github.com/zo0r/react-native-push-notification/blob/master/android/src/main/java/com/dieam/reactnativepushnotification/modules/RNPushNotificationHelper.java#L424
cancelScheduledNotification is the method that should be called. I have a feeling that may be the notification is not canceled as well or you have more than one notification with different ids but same text. So, the other ones won't go away from the notification center. Can you confirm that you are seeing the log messages present in the cancelScheduledNotification method?
I am trying to cancel two notifications. One that that has been delivered, and one scheduled but not delivered. The future one is correctly canceled, and this is shown the the log of the cancelScheduledNotification method. The one that has been delivered, and has an icon in the statusbar, does not show up in the log.
The two notifications would have different ids unless they are repeating notifications. So, you will need to cancel both the notifications separately.
Sent from my iPhone
On 03-Feb-2017, at 8:24 PM, Espen Jones [email protected] wrote:
I am trying to cancel two notifications. One that that has been delivered, and one scheduled but not delivered. The future one is correctly canceled, and this is shown the the log of the cancelScheduledNotification method. The one that has been delivered, and has an icon in the statusbar, does not show up in the log.
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
Hello.
For someone still facing this issue you can use the method clearLocalNotification(id). I've used the id as an integer, but you may try with string too, idk if it works.
I've tried it on Android and it's working (removing an already delivered notification). Hope it works.
Just leaving this here, https://stackoverflow.com/a/20007350/5844171
On the project, cancelLocalNotification calls this
NotificationManager notificationManager = notificationManager();
notificationManager.cancel(notificationID);
So if when you're generating your notification you have a tag property it's never being passed and thus not cleared
This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.