|
@@ -29,62 +29,6 @@ export default class NotificationsManager {
|
29
|
29
|
}
|
30
|
30
|
|
31
|
31
|
/**
|
32
|
|
- * Async function sending a notification without delay to the user
|
33
|
|
- *
|
34
|
|
- * @param title {String} Notification title
|
35
|
|
- * @param body {String} Notification body text
|
36
|
|
- * @returns {Promise<import("react").ReactText>} Notification Id
|
37
|
|
- */
|
38
|
|
- static async sendNotificationImmediately(title: string, body: string) {
|
39
|
|
- await NotificationsManager.askPermissions();
|
40
|
|
- return await Notifications.presentLocalNotificationAsync({
|
41
|
|
- title: title,
|
42
|
|
- body: body,
|
43
|
|
- });
|
44
|
|
- };
|
45
|
|
-
|
46
|
|
- /**
|
47
|
|
- * Async function sending notification at the specified time
|
48
|
|
- *
|
49
|
|
- * @param title Notification title
|
50
|
|
- * @param body Notification body text
|
51
|
|
- * @param time Time at which we should send the notification
|
52
|
|
- * @param data Data to send with the notification, used for listeners
|
53
|
|
- * @param androidChannelID
|
54
|
|
- * @returns {Promise<import("react").ReactText>} Notification Id
|
55
|
|
- */
|
56
|
|
- static async scheduleNotification(title: string, body: string, time: number, data: Object, androidChannelID: string): Promise<string> {
|
57
|
|
- await NotificationsManager.askPermissions();
|
58
|
|
- let date = new Date();
|
59
|
|
- date.setTime(time);
|
60
|
|
- return Notifications.scheduleLocalNotificationAsync(
|
61
|
|
- {
|
62
|
|
- title: title,
|
63
|
|
- body: body,
|
64
|
|
- data: data,
|
65
|
|
- ios: { // configuration for iOS.
|
66
|
|
- sound: true
|
67
|
|
- },
|
68
|
|
- android: { // configuration for Android.
|
69
|
|
- channelId: androidChannelID,
|
70
|
|
- }
|
71
|
|
- },
|
72
|
|
- {
|
73
|
|
- time: time,
|
74
|
|
- },
|
75
|
|
- );
|
76
|
|
- };
|
77
|
|
-
|
78
|
|
- /**
|
79
|
|
- * Async function used to cancel the notification of a specific ID
|
80
|
|
- * @param notificationID {Number} The notification ID
|
81
|
|
- * @returns {Promise}
|
82
|
|
- */
|
83
|
|
- static async cancelScheduledNotification(notificationID: number) {
|
84
|
|
- await Notifications.cancelScheduledNotificationAsync(notificationID);
|
85
|
|
- }
|
86
|
|
-
|
87
|
|
- /**
|
88
|
32
|
* Save expo token to allow sending notifications to this device.
|
89
|
33
|
* This token is unique for each device and won't change.
|
90
|
34
|
* It only needs to be fetched once, then it will be saved in storage.
|
|
@@ -105,13 +49,6 @@ export default class NotificationsManager {
|
105
|
49
|
}
|
106
|
50
|
}
|
107
|
51
|
|
108
|
|
- static async forceExpoTokenUpdate() {
|
109
|
|
- await NotificationsManager.askPermissions();
|
110
|
|
- let expoToken = await Notifications.getExpoPushTokenAsync();
|
111
|
|
- // Save token for instant use later on
|
112
|
|
- AsyncStorageManager.getInstance().savePref(AsyncStorageManager.getInstance().preferences.expoToken.key, expoToken);
|
113
|
|
- }
|
114
|
|
-
|
115
|
52
|
static getMachineNotificationWatchlist(callback: Function) {
|
116
|
53
|
let token = AsyncStorageManager.getInstance().preferences.expoToken.current;
|
117
|
54
|
if (token !== '') {
|