cancel local notification on android
See original GitHub issueHi! 👋
Firstly, thanks for your work on this project! 🙂
Today I used patch-package to patch react-native-push-notification@8.0.0
for the project I’m working on.
due to deprecation of cancelLocalNotifications
in favor of cancelLocalNotification
, the function in component/index.android.js needs to be renamed as well to cancelLocalNotification
Here is the diff that solved my problem:
diff --git a/node_modules/react-native-push-notification/component/index.android.js b/node_modules/react-native-push-notification/component/index.android.js
index 3496c04..0a609cb 100644
--- a/node_modules/react-native-push-notification/component/index.android.js
+++ b/node_modules/react-native-push-notification/component/index.android.js
@@ -36,8 +36,8 @@ NotificationsComponent.prototype.unsubscribeFromTopic = function(topic) {
RNPushNotification.unsubscribeFromTopic(topic);
};
-NotificationsComponent.prototype.cancelLocalNotifications = function(details) {
- RNPushNotification.cancelLocalNotifications(details);
+NotificationsComponent.prototype.cancelLocalNotification = function(details) {
+ RNPushNotification.cancelLocalNotification(details);
};
NotificationsComponent.prototype.clearLocalNotification = function(details, tag) {
This issue body was partially generated by patch-package.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:1
- Comments:9 (5 by maintainers)
Top Results From Across the Web
Stop Sending Local Notification android - Stack Overflow
1 Answer 1 ... This may help you, but I am not sure. Ref:How to stop AlarmManager when activity start. To Cancel Notification:...
Read more >How to Read and Cancel Local Notification Requests
In this tutorial, you will learn how to read and cancel local user notification request(UNNotificationRequest) or how to remove the pending ...
Read more >Android Notifications - Part 4, How to cancel & update - YouTube
In this video we have a look at how to cancel and update an existing notification in Android. Well it is pretty straight...
Read more >NotificationManager - Android Developers
This is also the same tag and id you pass to the cancel(int) or cancel(java.lang.String, int) method to clear ... Cancel all previously...
Read more >cancelAllNotifications - Notifee
This method does not cancel Android Foreground Service notifications. Property, Description, Optional. notificationIds. Copyright 2020 ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just release the patch. Thanks for this catch & PR!
@Dallas62 thanks for a quick reaction.
When calling
PushNotification.cancelLocalNotification
method it gets to this line: https://github.com/zo0r/react-native-push-notification/blob/17ad0aec909a6c489b3082e8f148d905de1f1bbd/index.js#L498Now, in
component/index.android.js
there is no such method ascancelLocalNotification
, onlycancelLocalNotifications
. As a result, this line gets executed, and nothing happens:https://github.com/zo0r/react-native-push-notification/blob/17ad0aec909a6c489b3082e8f148d905de1f1bbd/index.js#L38
Fix: There should be defined method
cancelLocalNotification
incomponent/index.android.js
file.