1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-27 10:32:58 +02:00
joplin/ReactNativeClient/lib/services/AlarmServiceDriver.android.ts

49 lines
1.2 KiB
TypeScript
Raw Normal View History

import { Notification } from 'lib/models/Alarm';
const PushNotification = require('react-native-push-notification');
export default class AlarmServiceDriver {
private PushNotification_:any = null;
PushNotificationHandler_() {
if (!this.PushNotification_) {
PushNotification.configure({
2019-07-29 15:43:53 +02:00
// (required) Called when a remote or local notification is opened or received
onNotification: function(notification:any) {
2019-07-29 15:43:53 +02:00
console.info('Notification was opened: ', notification);
// process the notification
},
popInitialNotification: true,
requestPermissions: true,
});
this.PushNotification_ = PushNotification;
}
return this.PushNotification_;
}
hasPersistentNotifications() {
return true;
}
notificationIsSet() {
2019-07-29 15:43:53 +02:00
throw new Error('Available only for non-persistent alarms');
}
async clearNotification(id:any) {
2019-09-19 23:51:18 +02:00
return this.PushNotificationHandler_().cancelLocalNotifications({ id: `${id}` });
}
2019-07-29 15:43:53 +02:00
async scheduleNotification(notification:Notification) {
const config = {
2019-09-19 23:51:18 +02:00
id: `${notification.id}`,
message: notification.title,
date: notification.date,
};
this.PushNotificationHandler_().localNotificationSchedule(config);
}
}