zo0r / react-native-push-notification

React Native Local and Remote Notifications
MIT License
6.76k stars 2.05k forks source link

Unable to cancel Delivered LocalNotifications using id #1018

Closed codemeall closed 3 years ago

codemeall commented 5 years ago

I am unable to cancel Delivered localnotification with their ID.

Linoa65 commented 5 years ago

I think there is a true problem with this feature. Many issues are open, and people says that it don't works, after it works, after it don't works ... For now I think the feature is broken, I tried different parameters to send to this module to cancel local notification, but nothing seems to work? We cannot handle properly the management of notification in our app on android side because of this.

Please, someone confirm that the feature is broken, or give a true solution with explanation, or a link, but not just a "Heyyy it works ty nice !".

Thanks.

Edit : After hours of tryharding, finally I got it works, the function was correctly called, but the notifications stayed. If you give a tagto your localNotification, the method clearLocalNotificationdon't work. I don't know why, maybe it's normal behavior, but if someone have an explanation, feel free to give it ! :D

ignasbol commented 5 years ago

@Linoa65 can confirm that removing tag from notification details allows notification to be cancelled with cancelLocalNotifications

athondapu commented 5 years ago

Hi All,

After a one day struggle I found the way to delete the delivered notification by ID. Here is how I solved my problem.

PushNotification.clearLocalNotification(parseInt(id, 10));

Please let me know if I am making any mistake.

disappearer commented 4 years ago

@athondapu Thank you, that worked for me 🙂 Although, typescript compiler is complaining and this method isn't mentioned anywhere in the docs.

HZSamir commented 4 years ago

@athondapu This did not work for me I have read elswhere that removing the tag attribute from localnotification was also an issue, but neither solutions worked. Could I please trouble you to share a full example? Thank you.

AntonOmelchuk commented 4 years ago

I have a problem with deleting delivered notifications, cancel Local Notification doesn't work, I tried all solutions that I read

winardis commented 4 years ago

Hi i'm also having the issue of removing delivered notifications i checked the documentation it seems only IOS has the function to remove delivered notification via PushNotificationIOS.removeDeliveredNotifications(identifiers); but what about the android's removal on delivered notifications

Dallas62 commented 4 years ago

Hi @willnaoosmit Check that: https://github.com/zo0r/react-native-push-notification/blob/master/index.js#L420

winardis commented 4 years ago

Hi @willnaoosmit Check that: https://github.com/zo0r/react-native-push-notification/blob/master/index.js#L420

Hi i checked on the documentation, the function of clearLocalNotification() is used to cancel operations not removing delivered notifications. Because i have tried using the function it works for canceling scheduled notifications, but not on removing delivered notifications

PushNotification.cancelLocalNotifications({ id: scheduledNotificationId });

cancelLocalNotifications The id parameter for PushNotification.localNotification is required for this operation. The id supplied will then be used for the cancel operation. https://github.com/zo0r/react-native-push-notification#1-cancellocalnotifications