react-native-notify-kit 10.1.0 → 10.2.1
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 +99 -96
- package/android/build.gradle +2 -2
- package/android/src/main/AndroidManifest.xml +0 -1
- package/android/src/main/java/app/notifee/core/ForegroundService.java +1 -0
- package/android/src/main/java/app/notifee/core/NotificationManager.java +21 -8
- package/android/src/main/java/app/notifee/core/RebootBroadcastReceiver.java +16 -0
- package/android/src/main/java/app/notifee/core/ReceiverService.java +18 -13
- package/android/src/main/java/app/notifee/core/model/NotificationAndroidActionModel.java +1 -2
- package/android/src/main/java/app/notifee/core/model/NotificationAndroidPressActionModel.java +3 -9
- package/android/src/main/java/app/notifee/core/model/TimestampTriggerModel.java +42 -27
- package/android/src/main/java/app/notifee/core/utility/IntentUtils.java +0 -28
- package/android/src/main/java/app/notifee/core/utility/PowerManagerUtils.java +79 -41
- package/android/src/main/java/app/notifee/core/utility/ResourceUtils.java +5 -1
- package/android/src/main/kotlin/io/invertase/notifee/NotifeeApiModule.kt +6 -6
- package/android/src/main/kotlin/io/invertase/notifee/NotifeeReactUtils.kt +1 -2
- package/android/src/test/java/app/notifee/core/model/TimestampTriggerModelTest.java +150 -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 +27 -13
- package/dist/types/Notification.d.ts +1 -1
- package/dist/types/NotificationIOS.d.ts +44 -21
- package/dist/types/NotificationIOS.js +15 -1
- package/dist/types/NotificationIOS.js.map +1 -1
- package/dist/types/PowerManagerInfo.d.ts +9 -4
- package/dist/types/Trigger.d.ts +45 -2
- package/dist/types/Trigger.js +22 -0
- package/dist/types/Trigger.js.map +1 -1
- package/dist/validators/validateIOSCategory.js +2 -2
- package/dist/validators/validateIOSCategory.js.map +1 -1
- package/dist/validators/validateTrigger.js +26 -1
- package/dist/validators/validateTrigger.js.map +1 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/ios/NotifeeCore/NotifeeCore+NSNotificationCenter.m +20 -10
- package/ios/NotifeeCore/NotifeeCore+UNUserNotificationCenter.h +1 -2
- package/ios/NotifeeCore/NotifeeCore+UNUserNotificationCenter.m +44 -35
- package/ios/NotifeeCore/NotifeeCore.m +1042 -119
- package/ios/NotifeeCore/NotifeeCoreUtil.h +36 -1
- package/ios/NotifeeCore/NotifeeCoreUtil.m +533 -9
- package/ios/RNNotifee/NotifeeApiModule.mm +2 -2
- package/package.json +1 -1
- package/src/index.ts +2 -0
- package/src/types/Module.ts +27 -13
- package/src/types/Notification.ts +1 -1
- package/src/types/NotificationIOS.ts +43 -28
- package/src/types/PowerManagerInfo.ts +9 -4
- package/src/types/Trigger.ts +45 -1
- package/src/validators/validateIOSCategory.ts +4 -2
- package/src/validators/validateTrigger.ts +38 -0
- package/src/version.ts +1 -1
|
@@ -17,9 +17,14 @@
|
|
|
17
17
|
|
|
18
18
|
#import "NotifeeCore+UNUserNotificationCenter.h"
|
|
19
19
|
|
|
20
|
+
#import "NotifeeCore.h"
|
|
20
21
|
#import "NotifeeCoreDelegateHolder.h"
|
|
21
22
|
#import "NotifeeCoreUtil.h"
|
|
22
23
|
|
|
24
|
+
@interface NotifeeCore (RollingTimestampTopUp)
|
|
25
|
+
+ (void)topUpRollingTimestampTriggersWithCompletion:(void (^)(NSError *error))completion;
|
|
26
|
+
@end
|
|
27
|
+
|
|
23
28
|
@implementation NotifeeCoreUNUserNotificationCenter
|
|
24
29
|
|
|
25
30
|
struct {
|
|
@@ -63,12 +68,7 @@ struct {
|
|
|
63
68
|
});
|
|
64
69
|
}
|
|
65
70
|
|
|
66
|
-
- (void)
|
|
67
|
-
if (notifUserInfo != nil) {
|
|
68
|
-
NSDictionary *notifeeNotification = notifUserInfo[kNotifeeUserInfoNotification];
|
|
69
|
-
_initialNoticationID = notifeeNotification[@"id"];
|
|
70
|
-
}
|
|
71
|
-
|
|
71
|
+
- (void)markInitialNotificationGathered {
|
|
72
72
|
_initialNotificationGathered = YES;
|
|
73
73
|
}
|
|
74
74
|
|
|
@@ -89,6 +89,24 @@ struct {
|
|
|
89
89
|
return nil;
|
|
90
90
|
}
|
|
91
91
|
|
|
92
|
+
- (BOOL)isRollingTimestampNotificationRequest:(UNNotificationRequest *)request {
|
|
93
|
+
if ([NotifeeCoreUtil isRollingInternalNotificationId:request.identifier]) {
|
|
94
|
+
return YES;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
NSDictionary *trigger = request.content.userInfo[kNotifeeUserInfoTrigger];
|
|
98
|
+
return [NotifeeCoreUtil isRollingTimestampTrigger:trigger];
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
- (void)topUpRollingTimestampTriggersForLifecycleEvent:(NSString *)eventName {
|
|
102
|
+
[NotifeeCore topUpRollingTimestampTriggersWithCompletion:^(NSError *error) {
|
|
103
|
+
if (error != nil) {
|
|
104
|
+
NSLog(@"NotifeeCore: Failed to top up rolling timestamp triggers after %@: %@", eventName,
|
|
105
|
+
error);
|
|
106
|
+
}
|
|
107
|
+
}];
|
|
108
|
+
}
|
|
109
|
+
|
|
92
110
|
#pragma mark - UNUserNotificationCenter Delegate Methods
|
|
93
111
|
|
|
94
112
|
// The method will be called on the delegate only if the application is in the
|
|
@@ -103,6 +121,8 @@ struct {
|
|
|
103
121
|
(void (^)(UNNotificationPresentationOptions options))completionHandler {
|
|
104
122
|
NSDictionary *notifeeNotification =
|
|
105
123
|
notification.request.content.userInfo[kNotifeeUserInfoNotification];
|
|
124
|
+
BOOL isRollingTimestampNotification =
|
|
125
|
+
[self isRollingTimestampNotificationRequest:notification.request];
|
|
106
126
|
|
|
107
127
|
// we only care about notifications created through notifee
|
|
108
128
|
if (notifeeNotification != nil) {
|
|
@@ -127,25 +147,16 @@ struct {
|
|
|
127
147
|
// if list or banner is true, ignore alert property
|
|
128
148
|
if (banner || list) {
|
|
129
149
|
if (banner) {
|
|
130
|
-
|
|
131
|
-
presentationOptions |= UNNotificationPresentationOptionBanner;
|
|
132
|
-
} else {
|
|
133
|
-
// for iOS 13 we need to set alert
|
|
134
|
-
presentationOptions |= UNNotificationPresentationOptionAlert;
|
|
135
|
-
}
|
|
150
|
+
presentationOptions |= UNNotificationPresentationOptionBanner;
|
|
136
151
|
}
|
|
137
152
|
|
|
138
153
|
if (list) {
|
|
139
|
-
|
|
140
|
-
presentationOptions |= UNNotificationPresentationOptionList;
|
|
141
|
-
} else {
|
|
142
|
-
// for iOS 13 we need to set alert
|
|
143
|
-
presentationOptions |= UNNotificationPresentationOptionAlert;
|
|
144
|
-
}
|
|
154
|
+
presentationOptions |= UNNotificationPresentationOptionList;
|
|
145
155
|
}
|
|
146
156
|
} else if (alert) {
|
|
147
157
|
// TODO: remove alert once it has been fully removed from the notifee API
|
|
148
|
-
presentationOptions |=
|
|
158
|
+
presentationOptions |=
|
|
159
|
+
UNNotificationPresentationOptionBanner | UNNotificationPresentationOptionList;
|
|
149
160
|
}
|
|
150
161
|
|
|
151
162
|
// Emit DELIVERED for every Notifee-owned notification presented in foreground.
|
|
@@ -160,6 +171,9 @@ struct {
|
|
|
160
171
|
}];
|
|
161
172
|
|
|
162
173
|
completionHandler(presentationOptions);
|
|
174
|
+
if (isRollingTimestampNotification) {
|
|
175
|
+
[self topUpRollingTimestampTriggersForLifecycleEvent:@"foreground delivery"];
|
|
176
|
+
}
|
|
163
177
|
|
|
164
178
|
} else if (_originalDelegate != nil && originalUNCDelegateRespondsTo.willPresentNotification) {
|
|
165
179
|
[_originalDelegate userNotificationCenter:center
|
|
@@ -174,15 +188,9 @@ struct {
|
|
|
174
188
|
// @react-native-firebase/messaging). Fall back to the platform default
|
|
175
189
|
// presentation options instead so the system shows the notification as it
|
|
176
190
|
// would if Notifee had not installed a delegate at all.
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
UNNotificationPresentationOptionList | UNNotificationPresentationOptionBadge);
|
|
181
|
-
} else {
|
|
182
|
-
completionHandler(UNNotificationPresentationOptionAlert |
|
|
183
|
-
UNNotificationPresentationOptionSound |
|
|
184
|
-
UNNotificationPresentationOptionBadge);
|
|
185
|
-
}
|
|
191
|
+
completionHandler(UNNotificationPresentationOptionBanner |
|
|
192
|
+
UNNotificationPresentationOptionSound | UNNotificationPresentationOptionList |
|
|
193
|
+
UNNotificationPresentationOptionBadge);
|
|
186
194
|
}
|
|
187
195
|
}
|
|
188
196
|
|
|
@@ -195,6 +203,8 @@ struct {
|
|
|
195
203
|
withCompletionHandler:(void (^)(void))completionHandler {
|
|
196
204
|
NSDictionary *notifeeNotification =
|
|
197
205
|
response.notification.request.content.userInfo[kNotifeeUserInfoNotification];
|
|
206
|
+
BOOL isRollingTimestampNotification =
|
|
207
|
+
[self isRollingTimestampNotificationRequest:response.notification.request];
|
|
198
208
|
|
|
199
209
|
_notificationOpenedAppID = notifeeNotification[@"id"];
|
|
200
210
|
|
|
@@ -234,6 +244,9 @@ struct {
|
|
|
234
244
|
}
|
|
235
245
|
}];
|
|
236
246
|
completionHandler();
|
|
247
|
+
if (isRollingTimestampNotification) {
|
|
248
|
+
[self topUpRollingTimestampTriggersForLifecycleEvent:@"notification response"];
|
|
249
|
+
}
|
|
237
250
|
return;
|
|
238
251
|
}
|
|
239
252
|
|
|
@@ -272,16 +285,12 @@ struct {
|
|
|
272
285
|
// store notification for getInitialNotification
|
|
273
286
|
_initialNotification = [eventDetail copy];
|
|
274
287
|
|
|
275
|
-
// post PRESS/ACTION_PRESS event
|
|
276
|
-
// Set is initial notification to true
|
|
277
|
-
if (_notificationOpenedAppID != nil && _initialNoticationID != nil &&
|
|
278
|
-
[_initialNoticationID isEqualToString:_notificationOpenedAppID]) {
|
|
279
|
-
eventDetail[@"initialNotification"] = @1;
|
|
280
|
-
}
|
|
281
|
-
|
|
282
288
|
[[NotifeeCoreDelegateHolder instance] didReceiveNotifeeCoreEvent:event];
|
|
283
289
|
|
|
284
290
|
completionHandler();
|
|
291
|
+
if (isRollingTimestampNotification) {
|
|
292
|
+
[self topUpRollingTimestampTriggersForLifecycleEvent:@"notification response"];
|
|
293
|
+
}
|
|
285
294
|
} else {
|
|
286
295
|
// Defensive: parseUNNotificationRequest: currently never returns nil,
|
|
287
296
|
// but if it did, the completionHandler contract must still be honored.
|