question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

cancel local notification on android

See original GitHub issue

Hi! 👋

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:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
Dallas62commented, Aug 24, 2021

Just release the patch. Thanks for this catch & PR!

1reaction
dimadeveatiicommented, Aug 24, 2021

@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#L498

Now, in component/index.android.js there is no such method as cancelLocalNotification, only cancelLocalNotifications. 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 in component/index.android.js file.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found