Android: Fixed cancelling of notification

pull/41/head
Laurent Cozic 2017-11-28 19:49:03 +00:00
parent 67a457b9c5
commit 1a610054d3
1 changed files with 8 additions and 3 deletions

View File

@ -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;