react-native-notify-kit 10.2.0 → 10.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/android/src/main/AndroidManifest.xml +0 -1
- package/android/src/main/java/app/notifee/core/ForegroundService.java +3 -1
- package/android/src/main/java/app/notifee/core/NotifeeAlarmManager.java +4 -2
- package/android/src/main/java/app/notifee/core/NotificationManager.java +43 -43
- package/android/src/main/java/app/notifee/core/ReceiverService.java +18 -13
- package/android/src/main/java/app/notifee/core/database/NotifeeCoreDatabase.java +1 -4
- package/android/src/main/java/app/notifee/core/model/ChannelModel.java +8 -13
- package/android/src/main/java/app/notifee/core/model/IntervalTriggerModel.java +2 -6
- package/android/src/main/java/app/notifee/core/model/NotificationAndroidActionModel.java +1 -2
- package/android/src/main/java/app/notifee/core/model/NotificationAndroidModel.java +30 -33
- package/android/src/main/java/app/notifee/core/model/NotificationAndroidPressActionModel.java +3 -9
- package/android/src/main/java/app/notifee/core/model/NotificationAndroidStyleModel.java +6 -4
- package/android/src/main/java/app/notifee/core/model/TimestampTriggerModel.java +7 -4
- package/android/src/main/java/app/notifee/core/utility/BundleValueReader.java +65 -0
- package/android/src/main/java/app/notifee/core/utility/IntentUtils.java +0 -28
- package/android/src/main/java/app/notifee/core/utility/ObjectUtils.java +1 -1
- package/android/src/main/java/app/notifee/core/utility/ParcelableCompatReader.java +64 -0
- package/android/src/main/java/app/notifee/core/utility/PowerManagerUtils.java +79 -41
- package/android/src/main/java/app/notifee/core/utility/ResourceUtils.java +3 -0
- package/android/src/main/kotlin/io/invertase/notifee/NotifeeApiModule.kt +1 -1
- package/android/src/main/kotlin/io/invertase/notifee/NotifeeInitProvider.kt +0 -26
- package/android/src/main/kotlin/io/invertase/notifee/NotifeeReactUtils.kt +1 -2
- package/android/src/test/java/app/notifee/core/NotifeeAlarmManagerCurrentBehaviorTest.java +446 -0
- package/android/src/test/java/app/notifee/core/NotificationManagerCreateTriggerNotificationCurrentBehaviorTest.java +203 -0
- package/android/src/test/java/app/notifee/core/NotificationManagerPressActionOptOutTest.java +180 -0
- package/android/src/test/java/app/notifee/core/NotificationReceiverHandlerInitialNotificationTest.java +157 -0
- package/android/src/test/java/app/notifee/core/ReceiverServiceInitialNotificationTest.java +169 -0
- package/android/src/test/java/app/notifee/core/model/ChannelModelTest.java +116 -0
- package/android/src/test/java/app/notifee/core/model/IntervalTriggerModelTest.java +71 -0
- package/android/src/test/java/app/notifee/core/model/NotificationAndroidModelTest.java +309 -0
- package/android/src/test/java/app/notifee/core/model/NotificationAndroidStyleModelTest.java +154 -0
- package/android/src/test/java/app/notifee/core/model/TimestampTriggerModelTest.java +296 -14
- package/android/src/test/java/app/notifee/core/utility/BundleValueReaderTest.java +131 -0
- package/android/src/test/java/app/notifee/core/utility/ObjectUtilsTest.java +142 -0
- package/android/src/test/java/app/notifee/core/utility/ParcelableCompatReaderTest.java +124 -0
- package/android/src/test/java/io/invertase/notifee/HeadlessTaskReactHostTest.java +136 -0
- package/android/src/test/java/io/invertase/notifee/NotifeeEventSubscriberRoutingTest.java +262 -0
- package/android/src/test/java/io/invertase/notifee/NotifeeReactUtilsDrawerTest.java +24 -0
- package/cli/dist/lib/patchPodfile.d.ts +3 -1
- package/cli/dist/lib/patchPodfile.js +125 -33
- package/cli/dist/lib/patchPodfile.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/types/Module.d.ts +20 -6
- package/dist/types/Notification.d.ts +5 -2
- package/dist/types/Notification.js +5 -2
- package/dist/types/Notification.js.map +1 -1
- package/dist/types/NotificationAndroid.d.ts +4 -0
- package/dist/types/NotificationAndroid.js +4 -0
- package/dist/types/NotificationAndroid.js.map +1 -1
- package/dist/types/PowerManagerInfo.d.ts +9 -4
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/ios/NotifeeCore/NotifeeCore.m +101 -114
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/types/Module.ts +20 -6
- package/src/types/Notification.ts +5 -2
- package/src/types/NotificationAndroid.ts +4 -0
- package/src/types/PowerManagerInfo.ts +9 -4
- package/src/version.ts +1 -1
|
@@ -111,8 +111,7 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
111
111
|
|
|
112
112
|
+ (NSString *)rollingPublicIdForRequest:(UNNotificationRequest *)request {
|
|
113
113
|
NSString *identifier = request.identifier;
|
|
114
|
-
NSString *mappedPublicId =
|
|
115
|
-
[NotifeeCoreUtil rollingPublicIdFromInternalNotificationId:identifier];
|
|
114
|
+
NSString *mappedPublicId = [NotifeeCoreUtil rollingPublicIdFromInternalNotificationId:identifier];
|
|
116
115
|
if ([mappedPublicId isKindOfClass:NSString.class] && [mappedPublicId length] > 0) {
|
|
117
116
|
return mappedPublicId;
|
|
118
117
|
}
|
|
@@ -155,11 +154,10 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
155
154
|
}
|
|
156
155
|
}
|
|
157
156
|
|
|
158
|
-
+ (NSMutableOrderedSet<NSString *> *)
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
record:(NSDictionary *)record {
|
|
157
|
+
+ (NSMutableOrderedSet<NSString *> *)
|
|
158
|
+
rollingIdentifiersForPublicId:(NSString *)publicId
|
|
159
|
+
pendingRequests:(NSArray<UNNotificationRequest *> *)pendingRequests
|
|
160
|
+
record:(NSDictionary *)record {
|
|
163
161
|
NSMutableOrderedSet<NSString *> *identifiers = [NSMutableOrderedSet orderedSet];
|
|
164
162
|
|
|
165
163
|
NSArray *scheduledIds = record[@"scheduledIds"];
|
|
@@ -186,12 +184,10 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
186
184
|
return identifiers;
|
|
187
185
|
}
|
|
188
186
|
|
|
189
|
-
+ (NSMutableOrderedSet<NSString *> *)
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
deliveredNotifications
|
|
194
|
-
record:(NSDictionary *)record {
|
|
187
|
+
+ (NSMutableOrderedSet<NSString *> *)
|
|
188
|
+
rollingDeliveredIdentifiersForPublicId:(NSString *)publicId
|
|
189
|
+
deliveredNotifications:(NSArray<UNNotification *> *)deliveredNotifications
|
|
190
|
+
record:(NSDictionary *)record {
|
|
195
191
|
NSMutableOrderedSet<NSString *> *identifiers = [NSMutableOrderedSet orderedSet];
|
|
196
192
|
|
|
197
193
|
NSArray *scheduledIds = record[@"scheduledIds"];
|
|
@@ -230,14 +226,12 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
230
226
|
return count;
|
|
231
227
|
}
|
|
232
228
|
|
|
233
|
-
+ (UNCalendarNotificationTrigger *)rollingOneShotTriggerForOccurrenceMs:
|
|
234
|
-
(NSNumber *)occurrenceMs {
|
|
229
|
+
+ (UNCalendarNotificationTrigger *)rollingOneShotTriggerForOccurrenceMs:(NSNumber *)occurrenceMs {
|
|
235
230
|
NSDate *date = [NSDate dateWithTimeIntervalSince1970:([occurrenceMs doubleValue] / 1000.0)];
|
|
236
|
-
NSDateComponents *components =
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
fromDate:date];
|
|
231
|
+
NSDateComponents *components = [[NSCalendar currentCalendar]
|
|
232
|
+
components:NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay | NSCalendarUnitHour |
|
|
233
|
+
NSCalendarUnitMinute | NSCalendarUnitSecond
|
|
234
|
+
fromDate:date];
|
|
241
235
|
|
|
242
236
|
return [UNCalendarNotificationTrigger triggerWithDateMatchingComponents:components repeats:NO];
|
|
243
237
|
}
|
|
@@ -256,11 +250,11 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
256
250
|
return rollingContent;
|
|
257
251
|
}
|
|
258
252
|
|
|
259
|
-
+ (UNMutableNotificationContent *)
|
|
260
|
-
|
|
261
|
-
|
|
253
|
+
+ (UNMutableNotificationContent *)
|
|
254
|
+
triggerNotificationContentForNotification:(NSDictionary *)notification
|
|
255
|
+
trigger:(NSDictionary *)trigger {
|
|
262
256
|
UNMutableNotificationContent *content = [self buildNotificationContent:notification
|
|
263
|
-
|
|
257
|
+
withTrigger:trigger];
|
|
264
258
|
|
|
265
259
|
if (@available(iOS 15.0, *)) {
|
|
266
260
|
if (notification[@"ios"][@"communicationInfo"] != nil) {
|
|
@@ -293,16 +287,17 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
293
287
|
|
|
294
288
|
+ (UNNotificationRequest *)rollingNotificationRequestForPublicId:(NSString *)publicId
|
|
295
289
|
occurrenceMs:(NSNumber *)occurrenceMs
|
|
296
|
-
content:
|
|
290
|
+
content:
|
|
291
|
+
(UNMutableNotificationContent *)content
|
|
297
292
|
error:(NSError **)error {
|
|
298
293
|
NSString *internalId = [NotifeeCoreUtil rollingInternalNotificationIdForPublicId:publicId
|
|
299
294
|
occurrenceMs:occurrenceMs];
|
|
300
295
|
if (internalId == nil) {
|
|
301
296
|
if (error != nil) {
|
|
302
|
-
*error =
|
|
303
|
-
rollingTimestampErrorWithCode:NotifeeCoreRollingErrorCodeInvalidTrigger
|
|
304
|
-
|
|
305
|
-
|
|
297
|
+
*error =
|
|
298
|
+
[self rollingTimestampErrorWithCode:NotifeeCoreRollingErrorCodeInvalidTrigger
|
|
299
|
+
message:@"NotifeeCore: Failed to create rolling timestamp "
|
|
300
|
+
@"notification identifier."];
|
|
306
301
|
}
|
|
307
302
|
return nil;
|
|
308
303
|
}
|
|
@@ -343,8 +338,7 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
343
338
|
|
|
344
339
|
+ (NSError *)scheduleRollingNotificationRequests:(NSArray<UNNotificationRequest *> *)requests
|
|
345
340
|
center:(UNUserNotificationCenter *)center
|
|
346
|
-
successfulIdentifiers:
|
|
347
|
-
(NSMutableSet<NSString *> *)successfulIdentifiers {
|
|
341
|
+
successfulIdentifiers:(NSMutableSet<NSString *> *)successfulIdentifiers {
|
|
348
342
|
if ([requests count] == 0) {
|
|
349
343
|
return nil;
|
|
350
344
|
}
|
|
@@ -378,7 +372,7 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
378
372
|
}
|
|
379
373
|
|
|
380
374
|
+ (BOOL)persistedRollingRecords:(NSDictionary *)persistedRecords
|
|
381
|
-
|
|
375
|
+
matchUpdatedRecords:(NSDictionary *)updatedRecords {
|
|
382
376
|
if ([persistedRecords count] != [updatedRecords count]) {
|
|
383
377
|
return NO;
|
|
384
378
|
}
|
|
@@ -394,8 +388,7 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
394
388
|
|
|
395
389
|
+ (NSArray<NSMutableDictionary *> *)rollingRebalanceStatesFromRecords:(NSDictionary *)records
|
|
396
390
|
nowMs:(NSNumber *)nowMs
|
|
397
|
-
requiredPublicId:
|
|
398
|
-
(NSString *)requiredPublicId
|
|
391
|
+
requiredPublicId:(NSString *)requiredPublicId
|
|
399
392
|
error:(NSError **)error {
|
|
400
393
|
NSMutableArray<NSMutableDictionary *> *states = [NSMutableArray array];
|
|
401
394
|
BOOL foundRequiredPublicId = requiredPublicId == nil;
|
|
@@ -435,10 +428,10 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
435
428
|
occurrenceMs:firstOccurrenceMs];
|
|
436
429
|
if (firstOccurrenceMs == nil || firstInternalId == nil) {
|
|
437
430
|
if (isRequiredPublicId && error != nil) {
|
|
438
|
-
*error =
|
|
439
|
-
rollingTimestampErrorWithCode:NotifeeCoreRollingErrorCodeInvalidTrigger
|
|
440
|
-
|
|
441
|
-
|
|
431
|
+
*error =
|
|
432
|
+
[self rollingTimestampErrorWithCode:NotifeeCoreRollingErrorCodeInvalidTrigger
|
|
433
|
+
message:@"NotifeeCore: Rolling timestamp trigger did not "
|
|
434
|
+
@"produce any future occurrences."];
|
|
442
435
|
return nil;
|
|
443
436
|
}
|
|
444
437
|
continue;
|
|
@@ -467,16 +460,15 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
467
460
|
return nil;
|
|
468
461
|
}
|
|
469
462
|
|
|
470
|
-
[states
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
463
|
+
[states
|
|
464
|
+
sortUsingComparator:^NSComparisonResult(NSDictionary *firstState, NSDictionary *secondState) {
|
|
465
|
+
return [self compareRollingRebalanceState:firstState otherState:secondState];
|
|
466
|
+
}];
|
|
474
467
|
|
|
475
468
|
return states;
|
|
476
469
|
}
|
|
477
470
|
|
|
478
|
-
+ (BOOL)prepareRollingRebalanceDesiredSchedulesForStates:
|
|
479
|
-
(NSArray<NSMutableDictionary *> *)states
|
|
471
|
+
+ (BOOL)prepareRollingRebalanceDesiredSchedulesForStates:(NSArray<NSMutableDictionary *> *)states
|
|
480
472
|
nowMs:(NSNumber *)nowMs
|
|
481
473
|
error:(NSError **)error {
|
|
482
474
|
for (NSMutableDictionary *state in states) {
|
|
@@ -489,15 +481,13 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
489
481
|
NSDictionary *notification = state[@"notification"];
|
|
490
482
|
NSDictionary *trigger = state[@"trigger"];
|
|
491
483
|
NSArray<NSNumber *> *occurrences =
|
|
492
|
-
[NotifeeCoreUtil rollingTimestampOccurrencesFromTrigger:trigger
|
|
493
|
-
nowMs:nowMs
|
|
494
|
-
maxCount:quota];
|
|
484
|
+
[NotifeeCoreUtil rollingTimestampOccurrencesFromTrigger:trigger nowMs:nowMs maxCount:quota];
|
|
495
485
|
if ([occurrences count] == 0) {
|
|
496
486
|
if (error != nil) {
|
|
497
|
-
*error =
|
|
498
|
-
rollingTimestampErrorWithCode:NotifeeCoreRollingErrorCodeInvalidTrigger
|
|
499
|
-
|
|
500
|
-
|
|
487
|
+
*error =
|
|
488
|
+
[self rollingTimestampErrorWithCode:NotifeeCoreRollingErrorCodeInvalidTrigger
|
|
489
|
+
message:@"NotifeeCore: Rolling timestamp trigger did not "
|
|
490
|
+
@"produce any future occurrences."];
|
|
501
491
|
}
|
|
502
492
|
return NO;
|
|
503
493
|
}
|
|
@@ -515,11 +505,10 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
515
505
|
}
|
|
516
506
|
|
|
517
507
|
NSError *requestError = nil;
|
|
518
|
-
UNNotificationRequest *request =
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
error:&requestError];
|
|
508
|
+
UNNotificationRequest *request = [self rollingNotificationRequestForPublicId:publicId
|
|
509
|
+
occurrenceMs:occurrenceMs
|
|
510
|
+
content:content
|
|
511
|
+
error:&requestError];
|
|
523
512
|
if (request == nil) {
|
|
524
513
|
if (error != nil) {
|
|
525
514
|
*error = requestError;
|
|
@@ -538,10 +527,10 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
538
527
|
|
|
539
528
|
if ([desiredIds count] == 0 || lastScheduledOccurrence == nil) {
|
|
540
529
|
if (error != nil) {
|
|
541
|
-
*error =
|
|
542
|
-
rollingTimestampErrorWithCode:NotifeeCoreRollingErrorCodeInvalidTrigger
|
|
543
|
-
|
|
544
|
-
|
|
530
|
+
*error =
|
|
531
|
+
[self rollingTimestampErrorWithCode:NotifeeCoreRollingErrorCodeInvalidTrigger
|
|
532
|
+
message:@"NotifeeCore: Rolling timestamp trigger did not "
|
|
533
|
+
@"produce any future occurrences."];
|
|
545
534
|
}
|
|
546
535
|
return NO;
|
|
547
536
|
}
|
|
@@ -562,10 +551,9 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
562
551
|
return YES;
|
|
563
552
|
}
|
|
564
553
|
|
|
565
|
-
+ (void)rollbackRollingRebalanceRemovedRequests:
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
center:(UNUserNotificationCenter *)center {
|
|
554
|
+
+ (void)rollbackRollingRebalanceRemovedRequests:(NSArray<UNNotificationRequest *> *)removedRequests
|
|
555
|
+
successfulNewIdentifiers:(NSSet<NSString *> *)successfulNewIdentifiers
|
|
556
|
+
center:(UNUserNotificationCenter *)center {
|
|
569
557
|
if ([successfulNewIdentifiers count] > 0) {
|
|
570
558
|
[self removeRollingPendingRequestsForIds:[successfulNewIdentifiers allObjects] center:center];
|
|
571
559
|
}
|
|
@@ -579,18 +567,16 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
579
567
|
|
|
580
568
|
+ (BOOL)rebalanceRollingTimestampTriggerRecords:(NSDictionary *)records
|
|
581
569
|
center:(UNUserNotificationCenter *)center
|
|
582
|
-
pendingRequests:
|
|
583
|
-
(NSArray<UNNotificationRequest *> *)pendingRequests
|
|
570
|
+
pendingRequests:(NSArray<UNNotificationRequest *> *)pendingRequests
|
|
584
571
|
nowMs:(NSNumber *)nowMs
|
|
585
572
|
refreshPublicId:(NSString *)refreshPublicId
|
|
586
573
|
requiredPublicId:(NSString *)requiredPublicId
|
|
587
574
|
error:(NSError **)error {
|
|
588
575
|
NSError *stateError = nil;
|
|
589
|
-
NSArray<NSMutableDictionary *> *states =
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
error:&stateError];
|
|
576
|
+
NSArray<NSMutableDictionary *> *states = [self rollingRebalanceStatesFromRecords:records
|
|
577
|
+
nowMs:nowMs
|
|
578
|
+
requiredPublicId:requiredPublicId
|
|
579
|
+
error:&stateError];
|
|
594
580
|
if (states == nil) {
|
|
595
581
|
if (error != nil) {
|
|
596
582
|
*error = stateError;
|
|
@@ -772,10 +758,10 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
772
758
|
[self removeRollingPendingRequestsForIds:[successfulNewIdentifiers allObjects] center:center];
|
|
773
759
|
|
|
774
760
|
if (error != nil) {
|
|
775
|
-
*error =
|
|
776
|
-
rollingTimestampErrorWithCode:NotifeeCoreRollingErrorCodeStorageFailed
|
|
777
|
-
|
|
778
|
-
|
|
761
|
+
*error =
|
|
762
|
+
[self rollingTimestampErrorWithCode:NotifeeCoreRollingErrorCodeStorageFailed
|
|
763
|
+
message:@"NotifeeCore: Failed to persist rolling timestamp "
|
|
764
|
+
@"trigger records after rebalance."];
|
|
779
765
|
}
|
|
780
766
|
return NO;
|
|
781
767
|
}
|
|
@@ -815,10 +801,10 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
815
801
|
dispatch_async([self rollingTimestampQueue], ^{
|
|
816
802
|
NSString *publicId = [self rollingPublicIdForNotification:notification];
|
|
817
803
|
if (publicId == nil) {
|
|
818
|
-
NSError *error =
|
|
819
|
-
rollingTimestampErrorWithCode:NotifeeCoreRollingErrorCodeInvalidTrigger
|
|
820
|
-
|
|
821
|
-
|
|
804
|
+
NSError *error =
|
|
805
|
+
[self rollingTimestampErrorWithCode:NotifeeCoreRollingErrorCodeInvalidTrigger
|
|
806
|
+
message:@"NotifeeCore: Rolling timestamp trigger requires a "
|
|
807
|
+
@"notification id."];
|
|
822
808
|
[self resolveBlock:block withError:error];
|
|
823
809
|
return;
|
|
824
810
|
}
|
|
@@ -881,8 +867,8 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
881
867
|
NSArray<UNNotification *> *deliveredNotifications = [self deliveredNotifications:center];
|
|
882
868
|
NSMutableOrderedSet<NSString *> *deliveredIdentifiersToRemove =
|
|
883
869
|
[self rollingDeliveredIdentifiersForPublicId:notificationId
|
|
884
|
-
|
|
885
|
-
|
|
870
|
+
deliveredNotifications:deliveredNotifications
|
|
871
|
+
record:record];
|
|
886
872
|
[self addString:notificationId toOrderedSet:deliveredIdentifiersToRemove];
|
|
887
873
|
if ([deliveredIdentifiersToRemove count] > 0) {
|
|
888
874
|
[center removeDeliveredNotificationsWithIdentifiers:[deliveredIdentifiersToRemove array]];
|
|
@@ -934,8 +920,7 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
934
920
|
cancelTrigger ? [self pendingNotificationRequests:center] : @[];
|
|
935
921
|
NSMutableOrderedSet<NSString *> *deliveredIdentifiersToRemove =
|
|
936
922
|
[NSMutableOrderedSet orderedSet];
|
|
937
|
-
NSMutableOrderedSet<NSString *> *pendingIdentifiersToRemove =
|
|
938
|
-
[NSMutableOrderedSet orderedSet];
|
|
923
|
+
NSMutableOrderedSet<NSString *> *pendingIdentifiersToRemove = [NSMutableOrderedSet orderedSet];
|
|
939
924
|
|
|
940
925
|
for (NSString *publicId in publicIds) {
|
|
941
926
|
NSDictionary *record = records[publicId];
|
|
@@ -943,8 +928,8 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
943
928
|
if (cancelDisplayed) {
|
|
944
929
|
NSMutableOrderedSet<NSString *> *rollingDeliveredIdentifiers =
|
|
945
930
|
[self rollingDeliveredIdentifiersForPublicId:publicId
|
|
946
|
-
|
|
947
|
-
|
|
931
|
+
deliveredNotifications:deliveredNotifications
|
|
932
|
+
record:record];
|
|
948
933
|
[deliveredIdentifiersToRemove unionOrderedSet:rollingDeliveredIdentifiers];
|
|
949
934
|
[self addString:publicId toOrderedSet:deliveredIdentifiersToRemove];
|
|
950
935
|
}
|
|
@@ -985,9 +970,7 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
985
970
|
+ (void)cancelNotification:(NSString *)notificationId
|
|
986
971
|
withNotificationType:(NSInteger)notificationType
|
|
987
972
|
withBlock:(notifeeMethodVoidBlock)block {
|
|
988
|
-
[self cancelRollingNotification:notificationId
|
|
989
|
-
withNotificationType:notificationType
|
|
990
|
-
block:block];
|
|
973
|
+
[self cancelRollingNotification:notificationId withNotificationType:notificationType block:block];
|
|
991
974
|
}
|
|
992
975
|
|
|
993
976
|
/**
|
|
@@ -1047,10 +1030,8 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
1047
1030
|
|
|
1048
1031
|
triggerNotification[@"date"] =
|
|
1049
1032
|
[NotifeeCoreUtil convertToTimestamp:deliveredNotification.date];
|
|
1050
|
-
triggerNotification[@"notification"] =
|
|
1051
|
-
|
|
1052
|
-
triggerNotification[@"trigger"] =
|
|
1053
|
-
request.content.userInfo[kNotifeeUserInfoTrigger];
|
|
1033
|
+
triggerNotification[@"notification"] = request.content.userInfo[kNotifeeUserInfoNotification];
|
|
1034
|
+
triggerNotification[@"trigger"] = request.content.userInfo[kNotifeeUserInfoTrigger];
|
|
1054
1035
|
|
|
1055
1036
|
if (triggerNotification[@"notification"] == nil) {
|
|
1056
1037
|
// parse remote notification
|
|
@@ -1139,8 +1120,7 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
1139
1120
|
NSString *notificationId = request.identifier;
|
|
1140
1121
|
NSString *rollingPublicId =
|
|
1141
1122
|
[NotifeeCoreUtil rollingPublicIdFromInternalNotificationId:notificationId];
|
|
1142
|
-
[self addString:(rollingPublicId != nil ? rollingPublicId : notificationId)
|
|
1143
|
-
toOrderedSet:ids];
|
|
1123
|
+
[self addString:(rollingPublicId != nil ? rollingPublicId : notificationId) toOrderedSet:ids];
|
|
1144
1124
|
}
|
|
1145
1125
|
|
|
1146
1126
|
NSDictionary *rollingRecords = [NotifeeCoreUtil getRollingTimestampTriggers];
|
|
@@ -1202,26 +1182,33 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
1202
1182
|
trigger:nil];
|
|
1203
1183
|
|
|
1204
1184
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
1205
|
-
[center
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1185
|
+
[center addNotificationRequest:request
|
|
1186
|
+
withCompletionHandler:^(NSError *error) {
|
|
1187
|
+
if (error == nil) {
|
|
1188
|
+
// When the app is in foreground, willPresentNotification: emits
|
|
1189
|
+
// DELIVERED for all Notifee-owned notifications. Only emit here
|
|
1190
|
+
// when the app is NOT active to avoid duplicate events.
|
|
1191
|
+
dispatch_async(dispatch_get_main_queue(), ^{
|
|
1192
|
+
BOOL isApplicationActive = NO;
|
|
1193
|
+
if (![NotifeeCoreUtil isAppExtension]) {
|
|
1194
|
+
UIApplication *application = [NotifeeCoreUtil notifeeUIApplication];
|
|
1195
|
+
if (application != nil) {
|
|
1196
|
+
isApplicationActive =
|
|
1197
|
+
application.applicationState == UIApplicationStateActive;
|
|
1198
|
+
}
|
|
1218
1199
|
}
|
|
1219
|
-
|
|
1200
|
+
if (!isApplicationActive) {
|
|
1201
|
+
[[NotifeeCoreDelegateHolder instance] didReceiveNotifeeCoreEvent:@{
|
|
1202
|
+
@"type" : @(NotifeeCoreEventTypeDelivered),
|
|
1203
|
+
@"detail" : @{
|
|
1204
|
+
@"notification" : notificationDetail,
|
|
1205
|
+
}
|
|
1206
|
+
}];
|
|
1207
|
+
}
|
|
1208
|
+
});
|
|
1220
1209
|
}
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
block(error);
|
|
1224
|
-
}];
|
|
1210
|
+
block(error);
|
|
1211
|
+
}];
|
|
1225
1212
|
});
|
|
1226
1213
|
});
|
|
1227
1214
|
}
|
|
@@ -1236,8 +1223,8 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
1236
1223
|
withTrigger:(NSDictionary *)trigger
|
|
1237
1224
|
withBlock:(notifeeMethodVoidBlock)block {
|
|
1238
1225
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
1239
|
-
UNMutableNotificationContent *content =
|
|
1240
|
-
|
|
1226
|
+
UNMutableNotificationContent *content =
|
|
1227
|
+
[self triggerNotificationContentForNotification:notification trigger:trigger];
|
|
1241
1228
|
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
|
|
1242
1229
|
|
|
1243
1230
|
NSMutableDictionary *notificationDetail = [notification mutableCopy];
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -33,3 +33,5 @@ export * from './types/NotificationIOS';
|
|
|
33
33
|
export * from './types/NotificationAndroid';
|
|
34
34
|
export * from './types/PowerManagerInfo';
|
|
35
35
|
export type { FcmRemoteMessage, FcmConfig } from './fcm/types';
|
|
36
|
+
export type { ModuleWithStatics } from './types/Module';
|
|
37
|
+
export type { WebNotificationSettings } from './types/NotificationWeb';
|
package/src/types/Module.ts
CHANGED
|
@@ -590,9 +590,17 @@ export interface Module {
|
|
|
590
590
|
isBatteryOptimizationEnabled(): Promise<boolean>;
|
|
591
591
|
|
|
592
592
|
/**
|
|
593
|
-
* API used to get information about the device and its power manager settings, including manufacturer, model, version and activity.
|
|
593
|
+
* API used to get best-effort information about the device and its power manager settings, including manufacturer, model, version and a known activity candidate.
|
|
594
594
|
*
|
|
595
|
-
*
|
|
595
|
+
* The returned `activity` is based on Notify Kit's manufacturer mapping and is not
|
|
596
|
+
* prevalidated with `PackageManager`. A non-null value does not guarantee that
|
|
597
|
+
* `openPowerManagerSettings()` can open that screen on the current device firmware.
|
|
598
|
+
*
|
|
599
|
+
* Notify Kit does not rely on Android 11+ package-visibility queries for this helper,
|
|
600
|
+
* so consumer apps do not need to add `<queries>` to use it.
|
|
601
|
+
*
|
|
602
|
+
* If `activity` is `null`, `openPowerManagerSettings()` will be a no-op because
|
|
603
|
+
* there is no known vendor-settings candidate.
|
|
596
604
|
*
|
|
597
605
|
* On iOS, an instance of `PowerManagerInfo` will be returned with `activity` set to `null`.
|
|
598
606
|
*
|
|
@@ -607,7 +615,7 @@ export interface Module {
|
|
|
607
615
|
* // 1. ask the user to adjust their Power Manager settings
|
|
608
616
|
* // ...
|
|
609
617
|
*
|
|
610
|
-
* // 2. open settings
|
|
618
|
+
* // 2. open settings best-effort
|
|
611
619
|
* await notifee.openPowerManagerSettings();
|
|
612
620
|
* }
|
|
613
621
|
* ```
|
|
@@ -617,9 +625,15 @@ export interface Module {
|
|
|
617
625
|
getPowerManagerInfo(): Promise<PowerManagerInfo>;
|
|
618
626
|
|
|
619
627
|
/**
|
|
620
|
-
* API used to
|
|
628
|
+
* API used to best-effort open known Android System power manager settings for the device.
|
|
629
|
+
*
|
|
630
|
+
* Call `getPowerManagerInfo()` first to decide whether to prompt the user. A
|
|
631
|
+
* non-null `activity` means Notify Kit has a known vendor-settings candidate, not
|
|
632
|
+
* that Android has confirmed the activity exists or is accessible.
|
|
621
633
|
*
|
|
622
|
-
*
|
|
634
|
+
* Notify Kit does not require consumer apps to add `<queries>` for this helper. If
|
|
635
|
+
* Android rejects or cannot resolve a vendor settings intent, the method safely
|
|
636
|
+
* falls back or no-ops instead of crashing.
|
|
623
637
|
*
|
|
624
638
|
* View the [Background Restrictions](/react-native/android/background-restrictions) documentation for more information.
|
|
625
639
|
*
|
|
@@ -632,7 +646,7 @@ export interface Module {
|
|
|
632
646
|
* // 1. ask the user to adjust their Power Manager settings
|
|
633
647
|
* // ...
|
|
634
648
|
*
|
|
635
|
-
* // 2. if yes,
|
|
649
|
+
* // 2. if yes, try to open settings
|
|
636
650
|
* await notifee.openPowerManagerSettings();
|
|
637
651
|
* }
|
|
638
652
|
* ```
|
|
@@ -358,9 +358,12 @@ export enum EventType {
|
|
|
358
358
|
DISMISSED = 0,
|
|
359
359
|
|
|
360
360
|
/**
|
|
361
|
-
* Event type is sent when a notification
|
|
361
|
+
* Event type is sent when the user presses a notification body and body tap is enabled.
|
|
362
362
|
*
|
|
363
|
-
* On Android,
|
|
363
|
+
* On Android, omitted `android.pressAction` defaults to opening the app and can emit this
|
|
364
|
+
* event. Setting `android.pressAction` to `null` disables the notification body tap and
|
|
365
|
+
* prevents `PRESS`/`getInitialNotification()` from that body tap. Action buttons emit
|
|
366
|
+
* `ACTION_PRESS` separately.
|
|
364
367
|
*
|
|
365
368
|
* On iOS, this event is always sent when the user presses a notification.
|
|
366
369
|
*/
|
|
@@ -1424,6 +1424,10 @@ export enum AndroidLaunchActivityFlag {
|
|
|
1424
1424
|
LAUNCHED_FROM_HISTORY = 10,
|
|
1425
1425
|
|
|
1426
1426
|
/**
|
|
1427
|
+
* @deprecated Android deprecated `FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET` in API 21.
|
|
1428
|
+
* Use `AndroidLaunchActivityFlag.NEW_DOCUMENT` for new code. This value remains
|
|
1429
|
+
* supported for backward compatibility with existing apps and persisted payloads.
|
|
1430
|
+
*
|
|
1427
1431
|
* See [FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET](https://developer.android.com/reference/android/content/Intent.html#FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET) on the official Android documentation for more information.
|
|
1428
1432
|
*/
|
|
1429
1433
|
CLEAR_WHEN_TASK_RESET = 11,
|
|
@@ -32,12 +32,17 @@ export interface PowerManagerInfo {
|
|
|
32
32
|
version?: string;
|
|
33
33
|
|
|
34
34
|
/**
|
|
35
|
-
* The
|
|
35
|
+
* The known vendor-settings activity candidate for this device manufacturer.
|
|
36
36
|
*
|
|
37
|
-
*
|
|
38
|
-
*
|
|
37
|
+
* This value is based on Notify Kit's manufacturer mapping. It is not prevalidated
|
|
38
|
+
* with `PackageManager`, and it is not a guarantee that the activity is installed
|
|
39
|
+
* or accessible on the current device firmware.
|
|
39
40
|
*
|
|
40
|
-
*
|
|
41
|
+
* Use this as a best-effort indicator of what steps the user may have to perform,
|
|
42
|
+
* in-order to prevent your app from being killed. `openPowerManagerSettings()`
|
|
43
|
+
* handles unavailable or rejected candidates safely.
|
|
44
|
+
*
|
|
45
|
+
* If no known activity candidate exists, value will be null.
|
|
41
46
|
*/
|
|
42
47
|
activity?: string | null;
|
|
43
48
|
}
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '10.
|
|
2
|
+
export const version = '10.3.0';
|