1
0
mirror of https://github.com/laurent22/joplin.git synced 2025-06-15 23:00:36 +02:00
Files
joplin/ReactNativeClient/lib/services/AlarmServiceDriver.android.js

35 lines
966 B
JavaScript
Raw Normal View History

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