You've already forked joplin
mirror of
https://github.com/laurent22/joplin.git
synced 2025-06-27 23:28:38 +02:00
All: Add support for application plugins (#3257)
This commit is contained in:
48
ReactNativeClient/lib/services/AlarmServiceDriver.android.ts
Normal file
48
ReactNativeClient/lib/services/AlarmServiceDriver.android.ts
Normal file
@ -0,0 +1,48 @@
|
||||
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({
|
||||
// (required) Called when a remote or local notification is opened or received
|
||||
onNotification: function(notification:any) {
|
||||
console.info('Notification was opened: ', notification);
|
||||
// process the notification
|
||||
},
|
||||
popInitialNotification: true,
|
||||
requestPermissions: true,
|
||||
});
|
||||
|
||||
this.PushNotification_ = PushNotification;
|
||||
}
|
||||
|
||||
return this.PushNotification_;
|
||||
}
|
||||
|
||||
hasPersistentNotifications() {
|
||||
return true;
|
||||
}
|
||||
|
||||
notificationIsSet() {
|
||||
throw new Error('Available only for non-persistent alarms');
|
||||
}
|
||||
|
||||
async clearNotification(id:any) {
|
||||
return this.PushNotificationHandler_().cancelLocalNotifications({ id: `${id}` });
|
||||
}
|
||||
|
||||
async scheduleNotification(notification:Notification) {
|
||||
const config = {
|
||||
id: `${notification.id}`,
|
||||
message: notification.title,
|
||||
date: notification.date,
|
||||
};
|
||||
|
||||
this.PushNotificationHandler_().localNotificationSchedule(config);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user