react-native-notifications icon indicating copy to clipboard operation
react-native-notifications copied to clipboard

cancelLocalNotification error

Open Rc85 opened this issue 5 years ago • 5 comments

Trying to cancel a local notification. I assume this is to remove the notification from the notification center

        const notificationIds = []
        const notification: Notification = {
          title: `My Takeouts`,
          body: 'You have a new order'
        };

        for (const id of notificationIds) {
          Notifications.cancelLocalNotification(id.toString());
        }

        const notificationId = Notifications.postLocalNotification(notification);

        notificationIds.push(notificationId);

I get a native error

java.lang String cannot be cast to java.lang.Double

Rc85 avatar Mar 22 '21 10:03 Rc85

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] avatar Apr 21 '21 10:04 stale[bot]

+1

jehee-choi avatar Apr 27 '21 09:04 jehee-choi

I've discovered that the notification id parameter in the function cancelLocalNotification(notificationId) must be a number even though the inferred type by the lib is string.

Notifications.cancelLocalNotification(1); will work while diplaying a linter error and Notifications.cancelLocalNotification('1'); will display no error on your code editor but will give you that native error.

douugdev avatar May 17 '21 14:05 douugdev

cancelLocalNotification doesn't work on android

also postLocalNotification fires immediately on android regardless of the fireDate

they have a not about this in the docs.

a-eid avatar May 19 '21 05:05 a-eid

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

stale[bot] avatar Jun 18 '21 06:06 stale[bot]