-
-
Notifications
You must be signed in to change notification settings - Fork 4.7k
/
AlarmServiceDriver.android.js
47 lines (36 loc) · 1.12 KB
/
AlarmServiceDriver.android.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
const PushNotification = require('react-native-push-notification');
class AlarmServiceDriver {
PushNotificationHandler_() {
if (!this.PushNotification_) {
PushNotification.configure({
// (required) Called when a remote or local notification is opened or received
onNotification: function(notification) {
console.info('Notification was opened: ', notification );
// process the notification
},
popInitialNotification: true,
requestPermissions: true,
});
this.PushNotification_ = PushNotification;
}
return this.PushNotification_;
}
hasPersistentNotifications() {
return true;
}
notificationIsSet(alarmId) {
throw new Error('Available only for non-persistent alarms');
}
async clearNotification(id) {
return this.PushNotificationHandler_().cancelLocalNotifications({id: id+''});
}
async scheduleNotification(notification) {
const config = {
id: notification.id + '',
message: notification.title,
date: notification.date,
};
this.PushNotificationHandler_().localNotificationSchedule(config);
}
}
module.exports = AlarmServiceDriver;