From 1a610054d3f3941f92c98c248bcc3ecf838e80be Mon Sep 17 00:00:00 2001 From: Laurent Cozic Date: Tue, 28 Nov 2017 19:49:03 +0000 Subject: [PATCH] Android: Fixed cancelling of notification --- .../lib/services/AlarmServiceDriver.android.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/ReactNativeClient/lib/services/AlarmServiceDriver.android.js b/ReactNativeClient/lib/services/AlarmServiceDriver.android.js index 5012aad12a..dce6c34a87 100644 --- a/ReactNativeClient/lib/services/AlarmServiceDriver.android.js +++ b/ReactNativeClient/lib/services/AlarmServiceDriver.android.js @@ -11,14 +11,19 @@ class AlarmServiceDriver { } async clearNotification(id) { - PushNotification.cancelLocalNotifications({ id: id }); + PushNotification.cancelLocalNotifications({ id: id + '' }); } async scheduleNotification(notification) { + // Arguments must be set in a certain way and certain format otherwise it cannot be + // cancelled later on. See: + // https://github.com/zo0r/react-native-push-notification/issues/570#issuecomment-337642922 const androidNotification = { - id: notification.id, - message: notification.title, // No idea what the limits are for title and body but set something reasonable anyway + id: notification.id + '', + message: notification.title, date: notification.date, + userInfo: { id: notification.id + '' }, + number: 0, }; if ('body' in notification) androidNotification.body = notification.body;