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.

cancelLocalNotification not working

See original GitHub issue

I have an issue trying to figure out how to make it work with cancelLocalNotification.

This is the local notification definition. Currently, working for Android.

PushNotification.localNotification({
      /* Android Only Properties */
      id: '1',
      ticker: 'Notification Center', // (optional)
      autoCancel: true, // (optional) default: true
      largeIcon: 'ic_launcher', // (optional) default: "ic_launcher"
      smallIcon: 'ic_notification', // (optional) default: "ic_notification" with fallback for "ic_launcher"
      subText: 'Alert', // (optional) default: none
      color: 'red', // (optional) default: system default
      vibrate: true, // (optional) default: true
      vibration: 300, // vibration length in milliseconds, ignored if vibrate=false, default: 1000
      tag: notification.type, // (optional) add tag to message
      group: 'group', // (optional) add group to message
      ongoing: false, // (optional) set whether this is an "ongoing" notification
      lat: geolocation.lat,
      lon: geolocation.lon,
      title: 'ALERT!', // (optional, for iOS this is only used in apple watch, the title will be the app name on other iOS devices)
      message: notification.message, // (required)
      playSound: false, // (optional) default: true
      soundName: 'default', // (optional) Sound to play when the notification is shown. Value of 'default' plays the default sound. It can be set to a custom sound such as 'android.resource://com.xyz/raw/my_sound'. It will look for the 'my_sound' audio file in 'res/raw' directory and play it. default: 'default' (default sound is played)
      actions: '["Yes", "No"]'  // (Android only) See the doc for notification actions to know more
    })

cancelAllLocalNotifications works but I don’t want to lose all my local notifications.

This is how I’m trying to cancel by attribute my local notifications PushNotification.cancelLocalNotifications({id: '1'}).

What am I doing wrong?

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:17 (4 by maintainers)

github_iconTop GitHub Comments

19reactions
johnnyrockensteincommented, May 14, 2018

Ok, I figured out why it wasn’t working for me.

The id cannot be an int, it must be a string. {id:‘33133’} works fine while {id: 33133} will not work

5reactions
somyapriyaquocommented, Feb 20, 2019

i am unable to cancel my notification in android , PushNotification.localNotificationSchedule({ message: ‘Time to record day mood’, title: ‘How was your day today!’, date: now, //date: new Date(Date.now() + 20000), repeatType: ‘day’, userInfo: { id: ‘2’, screenType: ‘DaysPerformance’ }, id: ‘2’ }); } disableLocalNotificationDays() { PushNotification.cancelLocalNotifications({ id: ‘2’ }); } still i am unable to cancel my notification

Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native PushNotification.cancelLocalNotifications not ...
I'm trying to do simple reminder app with RN and zo0r / react-native-push-notification and I'm not able to cancel notification from its ...
Read more >
cancelAllLocalNotifications not cl… | Apple Developer Forums
The local notifications is not working correctly in iOS 9. ... cancelLocalNotification seems to cancel the notification because [[UIApplication ...
Read more >
Local Notifications | React Native Notifications
You can cancel local notification by calling Notifications.cancelLocalNotification(notificationId) . Example: Copy. let someLocalNotification = Notifications ...
Read more >
Unity - Scripting API: iOS.NotificationServices.CancelLocalNotification
Is something described here not working as you expect it to? It might be a Known Issue. Please check with the Issue Tracker...
Read more >
CancelLocalNotification - Unreal Engine 5 Documentation
Whether you're a beginner or a seasoned pro, we have the help you need to succeed. ... Access Epic Games' premium fee-based support...
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