1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-03 22:37:35 +02:00
joplin/ReactNativeClient/lib/services/AlarmServiceDriver.android.js
2018-03-09 17:49:35 +00:00

35 lines
966 B
JavaScript

const PushNotification = require("react-native-push-notification");
class AlarmServiceDriver {
hasPersistentNotifications() {
return true;
}
notificationIsSet(alarmId) {
throw new Error("Available only for non-persistent alarms");
}
async clearNotification(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,
date: notification.date,
userInfo: { id: notification.id + "" },
number: 0,
};
if ("body" in notification) androidNotification.body = notification.body;
PushNotification.localNotificationSchedule(androidNotification);
}
}
module.exports = AlarmServiceDriver;