forked from mattermost/mattermost-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreact-native-notifications+4.1.3.patch
523 lines (498 loc) · 25.4 KB
/
react-native-notifications+4.1.3.patch
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/AndroidManifest.xml b/node_modules/react-native-notifications/lib/android/app/src/main/AndroidManifest.xml
index abd988a..4ac4725 100644
--- a/node_modules/react-native-notifications/lib/android/app/src/main/AndroidManifest.xml
+++ b/node_modules/react-native-notifications/lib/android/app/src/main/AndroidManifest.xml
@@ -3,6 +3,7 @@
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.wix.reactnativenotifications">
+ <uses-permission android:name="android.permission.WAKE_LOCK" />
<application>
<!--
@@ -22,6 +23,9 @@
android:name=".fcm.FcmInstanceIdRefreshHandlerService"
android:exported="false"
android:permission="android.permission.BIND_JOB_SERVICE" />
+ <receiver android:name=".core.notification.PushNotificationPublisher"
+ android:enabled="true"
+ android:exported="false" />
</application>
</manifest>
diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java
index db9eaba..af65d0e 100644
--- a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java
+++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java
@@ -100,7 +100,12 @@ public class RNNotificationsModule extends ReactContextBaseJavaModule implements
if(BuildConfig.DEBUG) Log.d(LOGTAG, "Native method invocation: postLocalNotification");
final Bundle notificationProps = Arguments.toBundle(notificationPropsMap);
final IPushNotification pushNotification = PushNotification.get(getReactApplicationContext().getApplicationContext(), notificationProps);
- pushNotification.onPostRequest(notificationId);
+ double date = notificationProps.getDouble("fireDate", 0);
+ if (date == 0) {
+ pushNotification.onPostRequest(notificationId);
+ } else {
+ pushNotification.onScheduleRequest(notificationId);
+ }
}
@ReactMethod
@@ -109,6 +114,12 @@ public class RNNotificationsModule extends ReactContextBaseJavaModule implements
notificationsDrawer.onNotificationClearRequest(notificationId);
}
+ @ReactMethod
+ public void cancelAllLocalNotifications() {
+ IPushNotificationsDrawer notificationDrawer = PushNotificationsDrawer.get(getReactApplicationContext().getApplicationContext());
+ notificationDrawer.onCancelAllLocalNotifications();
+ }
+
@ReactMethod
public void setCategories(ReadableArray categories) {
diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/helpers/ScheduleNotificationHelper.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/helpers/ScheduleNotificationHelper.java
new file mode 100644
index 0000000..dde4a2c
--- /dev/null
+++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/helpers/ScheduleNotificationHelper.java
@@ -0,0 +1,89 @@
+package com.wix.reactnativenotifications.core.helpers;
+
+import android.app.AlarmManager;
+import android.os.Build;
+import android.os.Bundle;
+import android.content.Context;
+import android.content.Intent;
+import android.app.PendingIntent;
+import android.content.SharedPreferences;
+import android.util.Log;
+
+import com.wix.reactnativenotifications.core.notification.PushNotificationProps;
+import com.wix.reactnativenotifications.core.notification.PushNotificationPublisher;
+
+import static com.wix.reactnativenotifications.Defs.LOGTAG;
+
+public class ScheduleNotificationHelper {
+ public static ScheduleNotificationHelper sInstance;
+ public static final String PREFERENCES_KEY = "rn_push_notification";
+ static final String NOTIFICATION_ID = "notificationId";
+
+ private final SharedPreferences scheduledNotificationsPersistence;
+ protected final Context mContext;
+
+ private ScheduleNotificationHelper(Context context) {
+ this.mContext = context;
+ this.scheduledNotificationsPersistence = context.getSharedPreferences(ScheduleNotificationHelper.PREFERENCES_KEY, Context.MODE_PRIVATE);
+ }
+
+ public static ScheduleNotificationHelper getInstance(Context context) {
+ if (sInstance == null) {
+ sInstance = new ScheduleNotificationHelper(context);
+ }
+ return sInstance;
+ }
+
+ public PendingIntent createPendingNotificationIntent(Integer notificationId, Bundle bundle) {
+ Intent notificationIntent = new Intent(mContext, PushNotificationPublisher.class);
+ notificationIntent.putExtra(ScheduleNotificationHelper.NOTIFICATION_ID, notificationId);
+ notificationIntent.putExtras(bundle);
+ return PendingIntent.getBroadcast(mContext, notificationId, notificationIntent, PendingIntent.FLAG_UPDATE_CURRENT);
+ }
+
+ public void schedulePendingNotificationIntent(PendingIntent intent, long fireDate) {
+ AlarmManager alarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
+
+ if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
+ alarmManager.setExact(AlarmManager.RTC_WAKEUP, fireDate, intent);
+ } else {
+ alarmManager.set(AlarmManager.RTC_WAKEUP, fireDate, intent);
+ }
+ }
+
+ public void cancelScheduledNotificationIntent(PendingIntent intent) {
+ AlarmManager alarmManager = (AlarmManager) mContext.getSystemService(Context.ALARM_SERVICE);
+ alarmManager.cancel(intent);
+ }
+
+ public boolean savePreferences(String notificationId, PushNotificationProps notificationProps) {
+ SharedPreferences.Editor editor = scheduledNotificationsPersistence.edit();
+ editor.putString(notificationId, notificationProps.toString());
+ commit(editor);
+
+ return scheduledNotificationsPersistence.contains(notificationId);
+ }
+
+ public void removePreference(String notificationId) {
+ if (scheduledNotificationsPersistence.contains(notificationId)) {
+ // remove it from local storage
+ SharedPreferences.Editor editor = scheduledNotificationsPersistence.edit();
+ editor.remove(notificationId);
+ commit(editor);
+ } else {
+ Log.w(LOGTAG, "Unable to find notification " + notificationId);
+ }
+ }
+
+ public java.util.Set<String> getPreferencesKeys() {
+ return scheduledNotificationsPersistence.getAll().keySet();
+ }
+
+ private static void commit(SharedPreferences.Editor editor) {
+ if (Build.VERSION.SDK_INT < 9) {
+ editor.commit();
+ } else {
+ editor.apply();
+ }
+ }
+}
diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/IPushNotification.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/IPushNotification.java
index 0d70024..b9e6c88 100644
--- a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/IPushNotification.java
+++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/IPushNotification.java
@@ -26,5 +26,21 @@ public interface IPushNotification {
*/
int onPostRequest(Integer notificationId);
+ /**
+ * Handle a request to schedule this notification.
+ *
+ * @param notificationId The specific ID to associated with the notification.
+ */
+ void onScheduleRequest(Integer notificationId);
+
+ /**
+ * Handle a request to post this scheduled notification.
+ *
+ * @param notificationId The specific ID to associated with the notification.
+ * @return The ID assigned to the notification.
+ */
+ int onPostScheduledRequest(Integer notificationId);
+
+
PushNotificationProps asProps();
}
diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java
index fe1fb94..c9e0301 100644
--- a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java
+++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java
@@ -8,6 +8,10 @@ import android.content.Context;
import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
+import android.util.Log;
+
+import androidx.core.app.NotificationCompat;
+import androidx.core.app.NotificationManagerCompat;
import com.facebook.react.bridge.ReactContext;
import com.wix.reactnativenotifications.core.AppLaunchHelper;
@@ -18,7 +22,9 @@ import com.wix.reactnativenotifications.core.InitialNotificationHolder;
import com.wix.reactnativenotifications.core.JsIOHelper;
import com.wix.reactnativenotifications.core.NotificationIntentAdapter;
import com.wix.reactnativenotifications.core.ProxyService;
+import com.wix.reactnativenotifications.core.helpers.ScheduleNotificationHelper;
+import static com.wix.reactnativenotifications.Defs.LOGTAG;
import static com.wix.reactnativenotifications.Defs.NOTIFICATION_OPENED_EVENT_NAME;
import static com.wix.reactnativenotifications.Defs.NOTIFICATION_RECEIVED_EVENT_NAME;
import static com.wix.reactnativenotifications.Defs.NOTIFICATION_RECEIVED_BACKGROUND_EVENT_NAME;
@@ -29,7 +35,7 @@ public class PushNotification implements IPushNotification {
final protected AppLifecycleFacade mAppLifecycleFacade;
final protected AppLaunchHelper mAppLaunchHelper;
final protected JsIOHelper mJsIOHelper;
- final protected PushNotificationProps mNotificationProps;
+ protected PushNotificationProps mNotificationProps;
final protected AppVisibilityListener mAppVisibilityListener = new AppVisibilityListener() {
@Override
public void onAppVisible() {
@@ -62,7 +68,7 @@ public class PushNotification implements IPushNotification {
}
@Override
- public void onReceived() throws InvalidNotificationException {
+ public void onReceived() {
if (!mAppLifecycleFacade.isAppVisible()) {
postNotification(null);
notifyReceivedBackgroundToJS();
@@ -81,6 +87,41 @@ public class PushNotification implements IPushNotification {
return postNotification(notificationId);
}
+ @Override
+ public void onScheduleRequest(Integer notificationId) {
+ Bundle bundle = mNotificationProps.asBundle();
+
+ if (bundle.getString("body") == null) {
+ Log.e(LOGTAG, "No message specified for the scheduled notification");
+ return;
+ }
+
+ double date = bundle.getDouble("fireDate", 0);
+ if (date == 0) {
+ Log.e(LOGTAG, "No date specified for the scheduled notification");
+ return;
+ }
+
+ ScheduleNotificationHelper helper = ScheduleNotificationHelper.getInstance(mContext);
+ String notificationIdStr = Integer.toString(notificationId);
+ boolean isSaved = helper.savePreferences(notificationIdStr, mNotificationProps);
+ if (!isSaved) {
+ Log.e(LOGTAG, "Failed to save preference for notificationId " + notificationIdStr);
+ }
+
+ PendingIntent pendingIntent = helper.createPendingNotificationIntent(notificationId, bundle);
+ long fireDate = (long) date;
+ helper.schedulePendingNotificationIntent(pendingIntent, fireDate);
+ }
+
+ @Override
+ public int onPostScheduledRequest(Integer notificationId) {
+ ScheduleNotificationHelper helper = ScheduleNotificationHelper.getInstance(mContext);
+ helper.removePreference(String.valueOf(notificationId));
+
+ return postNotification(notificationId);
+ }
+
@Override
public PushNotificationProps asProps() {
return mNotificationProps.copy();
@@ -143,15 +184,16 @@ public class PushNotification implements IPushNotification {
}
protected Notification buildNotification(PendingIntent intent) {
- return getNotificationBuilder(intent).build();
+ NotificationCompat.Builder builder = getNotificationBuilder(intent);
+ return builder.build();
}
- protected Notification.Builder getNotificationBuilder(PendingIntent intent) {
- final Notification.Builder notification = new Notification.Builder(mContext)
+ protected NotificationCompat.Builder getNotificationBuilder(PendingIntent intent) {
+ final NotificationCompat.Builder notification = new NotificationCompat.Builder(mContext, DEFAULT_CHANNEL_ID)
.setContentTitle(mNotificationProps.getTitle())
.setContentText(mNotificationProps.getBody())
.setContentIntent(intent)
- .setDefaults(Notification.DEFAULT_ALL)
+ .setDefaults(NotificationCompat.DEFAULT_ALL)
.setAutoCancel(true);
setUpIcon(notification);
@@ -166,7 +208,7 @@ public class PushNotification implements IPushNotification {
return notification;
}
- private void setUpIcon(Notification.Builder notification) {
+ private void setUpIcon(NotificationCompat.Builder notification) {
int iconResId = getAppResourceId("notification_icon", "drawable");
if (iconResId != 0) {
notification.setSmallIcon(iconResId);
@@ -177,7 +219,7 @@ public class PushNotification implements IPushNotification {
setUpIconColor(notification);
}
- private void setUpIconColor(Notification.Builder notification) {
+ private void setUpIconColor(NotificationCompat.Builder notification) {
int colorResID = getAppResourceId("colorAccent", "color");
if (colorResID != 0 && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
int color = mContext.getResources().getColor(colorResID);
@@ -192,7 +234,7 @@ public class PushNotification implements IPushNotification {
}
protected void postNotification(int id, Notification notification) {
- final NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
+ final NotificationManagerCompat notificationManager = NotificationManagerCompat.from(mContext);
notificationManager.notify(id, notification);
}
diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotificationPublisher.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotificationPublisher.java
new file mode 100644
index 0000000..5b64593
--- /dev/null
+++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotificationPublisher.java
@@ -0,0 +1,27 @@
+package com.wix.reactnativenotifications.core.notification;
+
+import android.app.Application;
+import android.content.BroadcastReceiver;
+import android.content.Context;
+import android.content.Intent;
+import android.util.Log;
+
+import static com.wix.reactnativenotifications.Defs.LOGTAG;
+
+public class PushNotificationPublisher extends BroadcastReceiver {
+ final static String NOTIFICATION_ID = "notificationId";
+
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ Log.d(LOGTAG, "Received scheduled notification intent");
+ int notificationId = intent.getIntExtra(NOTIFICATION_ID, 0);
+ long currentTime = System.currentTimeMillis();
+
+ Application applicationContext = (Application) context.getApplicationContext();
+ final IPushNotification pushNotification = PushNotification.get(applicationContext, intent.getExtras());
+
+ Log.i(LOGTAG, "PushNotificationPublisher: Prepare To Publish: " + notificationId + ", Now Time: " + currentTime);
+
+ pushNotification.onPostScheduledRequest(notificationId);
+ }
+}
\ No newline at end of file
diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notificationdrawer/IPushNotificationsDrawer.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notificationdrawer/IPushNotificationsDrawer.java
index e22cd62..48aa1cd 100644
--- a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notificationdrawer/IPushNotificationsDrawer.java
+++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notificationdrawer/IPushNotificationsDrawer.java
@@ -11,4 +11,5 @@ public interface IPushNotificationsDrawer {
void onNotificationClearRequest(int id);
void onNotificationClearRequest(String tag, int id);
void onAllNotificationsClearRequest();
+ void onCancelAllLocalNotifications();
}
diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notificationdrawer/PushNotificationsDrawer.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notificationdrawer/PushNotificationsDrawer.java
index a14089f..1262e6d 100644
--- a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notificationdrawer/PushNotificationsDrawer.java
+++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notificationdrawer/PushNotificationsDrawer.java
@@ -2,9 +2,15 @@ package com.wix.reactnativenotifications.core.notificationdrawer;
import android.app.Activity;
import android.app.NotificationManager;
+import android.app.PendingIntent;
import android.content.Context;
+import android.os.Bundle;
+import android.util.Log;
import com.wix.reactnativenotifications.core.AppLaunchHelper;
+import com.wix.reactnativenotifications.core.helpers.ScheduleNotificationHelper;
+
+import static com.wix.reactnativenotifications.Defs.LOGTAG;
public class PushNotificationsDrawer implements IPushNotificationsDrawer {
@@ -62,4 +68,37 @@ public class PushNotificationsDrawer implements IPushNotificationsDrawer {
final NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancelAll();
}
+
+ @Override
+ public void onCancelAllLocalNotifications() {
+ onAllNotificationsClearRequest();
+ cancelAllScheduledNotifications();
+ }
+
+ protected void cancelAllScheduledNotifications() {
+ Log.i(LOGTAG, "Cancelling all scheduled notifications");
+ ScheduleNotificationHelper helper = ScheduleNotificationHelper.getInstance(mContext);
+
+ for (String notificationId : helper.getPreferencesKeys()) {
+ cancelScheduledNotification(notificationId);
+ }
+ }
+
+ protected void cancelScheduledNotification(String notificationId) {
+ Log.i(LOGTAG, "Cancelling scheduled notification: " + notificationId);
+
+ ScheduleNotificationHelper helper = ScheduleNotificationHelper.getInstance(mContext);
+
+ // Remove it from the alarm manger schedule
+ Bundle bundle = new Bundle();
+ bundle.putString("id", notificationId);
+ PendingIntent pendingIntent = helper.createPendingNotificationIntent(Integer.parseInt(notificationId), bundle);
+ helper.cancelScheduledNotificationIntent(pendingIntent);
+
+ helper.removePreference(notificationId);
+
+ // Remove it from the notification center
+ final NotificationManager notificationManager = (NotificationManager) mContext.getSystemService(Context.NOTIFICATION_SERVICE);
+ notificationManager.cancel(Integer.parseInt(notificationId));
+ }
}
diff --git a/node_modules/react-native-notifications/lib/dist/DTO/Notification.d.ts b/node_modules/react-native-notifications/lib/dist/DTO/Notification.d.ts
index 7b2b3b1..3a2f872 100644
--- a/node_modules/react-native-notifications/lib/dist/DTO/Notification.d.ts
+++ b/node_modules/react-native-notifications/lib/dist/DTO/Notification.d.ts
@@ -1,4 +1,5 @@
export declare class Notification {
+ fireDate?: number | string;
identifier: string;
payload: any;
constructor(payload: object);
diff --git a/node_modules/react-native-notifications/lib/dist/DTO/Notification.js b/node_modules/react-native-notifications/lib/dist/DTO/Notification.js
index ad7fc1a..a04ec6b 100644
--- a/node_modules/react-native-notifications/lib/dist/DTO/Notification.js
+++ b/node_modules/react-native-notifications/lib/dist/DTO/Notification.js
@@ -5,6 +5,7 @@ class Notification {
constructor(payload) {
this.payload = payload;
this.identifier = this.payload.identifier;
+ this.fireDate = undefined;
}
get title() {
return this.payload.title;
diff --git a/node_modules/react-native-notifications/lib/dist/Notifications.d.ts b/node_modules/react-native-notifications/lib/dist/Notifications.d.ts
index 6e49fd4..1d94217 100644
--- a/node_modules/react-native-notifications/lib/dist/Notifications.d.ts
+++ b/node_modules/react-native-notifications/lib/dist/Notifications.d.ts
@@ -37,6 +37,10 @@ export declare class NotificationsRoot {
* cancelLocalNotification
*/
cancelLocalNotification(notificationId: number): void;
+ /**
+ * cancelAllLocalNotifications
+ */
+ cancelAllLocalNotifications(): void;
/**
* removeAllDeliveredNotifications
*/
diff --git a/node_modules/react-native-notifications/lib/dist/Notifications.js b/node_modules/react-native-notifications/lib/dist/Notifications.js
index 44ab53f..8000701 100644
--- a/node_modules/react-native-notifications/lib/dist/Notifications.js
+++ b/node_modules/react-native-notifications/lib/dist/Notifications.js
@@ -55,6 +55,12 @@ class NotificationsRoot {
cancelLocalNotification(notificationId) {
return this.commands.cancelLocalNotification(notificationId);
}
+ /**
+ * cancelAllLocalNotifications
+ */
+ cancelAllLocalNotifications() {
+ this.commands.cancelAllLocalNotifications();
+ }
/**
* removeAllDeliveredNotifications
*/
diff --git a/node_modules/react-native-notifications/lib/dist/interfaces/NotificationCategory.d.ts b/node_modules/react-native-notifications/lib/dist/interfaces/NotificationCategory.d.ts
index 0e78cb5..ae90bd1 100644
--- a/node_modules/react-native-notifications/lib/dist/interfaces/NotificationCategory.d.ts
+++ b/node_modules/react-native-notifications/lib/dist/interfaces/NotificationCategory.d.ts
@@ -13,5 +13,5 @@ export declare class NotificationAction {
title: string;
authenticationRequired: boolean;
textInput?: NotificationTextInput;
- constructor(identifier: string, activationMode: 'foreground' | 'authenticationRequired' | 'destructive', title: string, authenticationRequired: boolean, textInput?: NotificationTextInput);
+ constructor(identifier: string, activationMode: 'background' | 'foreground' | 'authenticationRequired' | 'destructive', title: string, authenticationRequired: boolean, textInput?: NotificationTextInput);
}
diff --git a/node_modules/react-native-notifications/lib/ios/RNNotificationCenter.m b/node_modules/react-native-notifications/lib/ios/RNNotificationCenter.m
index 7452523..a093262 100644
--- a/node_modules/react-native-notifications/lib/ios/RNNotificationCenter.m
+++ b/node_modules/react-native-notifications/lib/ios/RNNotificationCenter.m
@@ -83,7 +83,7 @@
for (UNNotification *notification in notifications) {
[formattedNotifications addObject:[RCTConvert UNNotificationPayload:notification]];
}
- callback(@[formattedNotifications]);
+ callback(formattedNotifications);
}];
}
diff --git a/node_modules/react-native-notifications/lib/src/Notifications.ts b/node_modules/react-native-notifications/lib/src/Notifications.ts
index 0848f6d..ceb271d 100644
--- a/node_modules/react-native-notifications/lib/src/Notifications.ts
+++ b/node_modules/react-native-notifications/lib/src/Notifications.ts
@@ -80,6 +80,13 @@ export class NotificationsRoot {
return this.commands.cancelLocalNotification(notificationId);
}
+ /**
+ * cancelAllLocalNotifications
+ */
+ public cancelAllLocalNotifications() {
+ this.commands.cancelAllLocalNotifications();
+ }
+
/**
* removeAllDeliveredNotifications
*/
diff --git a/node_modules/react-native-notifications/lib/src/NotificationsIOS.ts b/node_modules/react-native-notifications/lib/src/NotificationsIOS.ts
index 98fc19d..0c8ea3d 100644
--- a/node_modules/react-native-notifications/lib/src/NotificationsIOS.ts
+++ b/node_modules/react-native-notifications/lib/src/NotificationsIOS.ts
@@ -52,13 +52,6 @@ export class NotificationsIOS {
return this.commands.setBadgeCount(count);
}
- /**
- * cancelAllLocalNotifications
- */
- public cancelAllLocalNotifications() {
- this.commands.cancelAllLocalNotifications();
- }
-
/**
* checkPermissions
*/