React Native PushNotification.cancelLocalNotifications not working

Viewed 151

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 actions. This is how notification is created:

PushNotification.localNotificationSchedule({
  id: id.toString(),
  number: 0,
  userInfo: {
    id: id.toString(),
  },
  channelId: 'channel-@' + id,
  title: title,
  message: text,
  ongoing: ongoing,
  date: new Date(dateFrom),
  allowWhileIdle: true,
  actions: ['Complete'],
  playSound: true,
  invokeApp: false,
  autoCancel: false,
  data: {
    id: id.toString(),
  },
});

id returns simple integer based on previous notifications - 1 or 2 or 3 etc.

I've got one 'Complete' action with this code in index.js

onAction: function (notification) {
    finishNote(notification.data.id)
  },

and with pushing the 'complete'button i'm calling this function from external file:

export default function finishNote(notificationId) {
    PushNotification.cancelLocalNotifications({id: notificationId.toString()})
}

After pushing the 'complete' button nothing happens, i've tried

PushNotification.cancelAllLocalNotifications()

And this works, however, I need to cancel specific ones.

Any ideas, please?

0 Answers
Related