react-native-notify-kit 10.3.2 → 10.3.3
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/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/ios/NotifeeCore/NotifeeCore+NSNotificationCenter.m +6 -0
- package/ios/NotifeeCore/NotifeeCore+UNUserNotificationCenter.m +95 -20
- package/ios/NotifeeCore/NotifeeCore.m +13 -0
- package/ios/RNNotifee/NotifeeApiModule.mm +7 -0
- package/package.json +2 -2
- package/src/version.ts +1 -1
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "10.3.
|
|
1
|
+
export declare const version = "10.3.3";
|
package/dist/version.js
CHANGED
|
@@ -24,6 +24,10 @@
|
|
|
24
24
|
+ (void)topUpRollingTimestampTriggersWithCompletion:(void (^)(NSError *error))completion;
|
|
25
25
|
@end
|
|
26
26
|
|
|
27
|
+
@interface NotifeeCoreUNUserNotificationCenter (Rechain)
|
|
28
|
+
- (void)rechainUserNotificationCenterDelegate;
|
|
29
|
+
@end
|
|
30
|
+
|
|
27
31
|
@implementation NotifeeCoreNSNotificationCenter
|
|
28
32
|
|
|
29
33
|
+ (instancetype)instance {
|
|
@@ -75,6 +79,8 @@
|
|
|
75
79
|
}
|
|
76
80
|
|
|
77
81
|
- (void)application_didBecomeActiveNotification:(nonnull NSNotification *)notification {
|
|
82
|
+
[[NotifeeCoreUNUserNotificationCenter instance] rechainUserNotificationCenterDelegate];
|
|
83
|
+
|
|
78
84
|
[NotifeeCore topUpRollingTimestampTriggersWithCompletion:^(NSError *error) {
|
|
79
85
|
if (error != nil) {
|
|
80
86
|
NSLog(@"NotifeeCore: Failed to top up rolling timestamp triggers after app became active: %@",
|
|
@@ -21,10 +21,63 @@
|
|
|
21
21
|
#import "NotifeeCoreDelegateHolder.h"
|
|
22
22
|
#import "NotifeeCoreUtil.h"
|
|
23
23
|
|
|
24
|
+
typedef void (^NotifeeCorePresentationCompletionHandler)(UNNotificationPresentationOptions options);
|
|
25
|
+
typedef void (^NotifeeCoreVoidCompletionHandler)(void);
|
|
26
|
+
|
|
24
27
|
@interface NotifeeCore (RollingTimestampTopUp)
|
|
25
28
|
+ (void)topUpRollingTimestampTriggersWithCompletion:(void (^)(NSError *error))completion;
|
|
26
29
|
@end
|
|
27
30
|
|
|
31
|
+
@interface NotifeeCoreUNUserNotificationCenter ()
|
|
32
|
+
- (void)refreshOriginalDelegateSelectorFlags;
|
|
33
|
+
- (void)rechainUserNotificationCenterDelegate;
|
|
34
|
+
@end
|
|
35
|
+
|
|
36
|
+
static NotifeeCorePresentationCompletionHandler NotifeeCoreOneShotPresentationCompletionHandler(
|
|
37
|
+
NotifeeCorePresentationCompletionHandler completionHandler) {
|
|
38
|
+
NSObject *completionLock = [NSObject new];
|
|
39
|
+
__block BOOL completionCalled = NO;
|
|
40
|
+
|
|
41
|
+
NotifeeCorePresentationCompletionHandler oneShotCompletionHandler =
|
|
42
|
+
^(UNNotificationPresentationOptions options) {
|
|
43
|
+
BOOL shouldCallCompletion = NO;
|
|
44
|
+
@synchronized(completionLock) {
|
|
45
|
+
if (!completionCalled) {
|
|
46
|
+
completionCalled = YES;
|
|
47
|
+
shouldCallCompletion = YES;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (shouldCallCompletion && completionHandler != nil) {
|
|
52
|
+
completionHandler(options);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
return [oneShotCompletionHandler copy];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
static NotifeeCoreVoidCompletionHandler NotifeeCoreOneShotVoidCompletionHandler(
|
|
60
|
+
NotifeeCoreVoidCompletionHandler completionHandler) {
|
|
61
|
+
NSObject *completionLock = [NSObject new];
|
|
62
|
+
__block BOOL completionCalled = NO;
|
|
63
|
+
|
|
64
|
+
NotifeeCoreVoidCompletionHandler oneShotCompletionHandler = ^{
|
|
65
|
+
BOOL shouldCallCompletion = NO;
|
|
66
|
+
@synchronized(completionLock) {
|
|
67
|
+
if (!completionCalled) {
|
|
68
|
+
completionCalled = YES;
|
|
69
|
+
shouldCallCompletion = YES;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
if (shouldCallCompletion && completionHandler != nil) {
|
|
74
|
+
completionHandler();
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
return [oneShotCompletionHandler copy];
|
|
79
|
+
}
|
|
80
|
+
|
|
28
81
|
@implementation NotifeeCoreUNUserNotificationCenter
|
|
29
82
|
|
|
30
83
|
struct {
|
|
@@ -47,25 +100,41 @@ struct {
|
|
|
47
100
|
}
|
|
48
101
|
|
|
49
102
|
- (void)observe {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
103
|
+
[self rechainUserNotificationCenterDelegate];
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
- (void)refreshOriginalDelegateSelectorFlags {
|
|
107
|
+
id<UNUserNotificationCenterDelegate> originalDelegate = self.originalDelegate;
|
|
108
|
+
|
|
109
|
+
originalUNCDelegateRespondsTo.openSettingsForNotification =
|
|
110
|
+
originalDelegate != nil &&
|
|
111
|
+
[originalDelegate respondsToSelector:@selector(userNotificationCenter:
|
|
112
|
+
openSettingsForNotification:)];
|
|
113
|
+
originalUNCDelegateRespondsTo.willPresentNotification =
|
|
114
|
+
originalDelegate != nil &&
|
|
115
|
+
[originalDelegate respondsToSelector:@selector
|
|
116
|
+
(userNotificationCenter:willPresentNotification:withCompletionHandler:)];
|
|
117
|
+
originalUNCDelegateRespondsTo.didReceiveNotificationResponse =
|
|
118
|
+
originalDelegate != nil &&
|
|
119
|
+
[originalDelegate
|
|
60
120
|
respondsToSelector:@selector(userNotificationCenter:
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
121
|
+
didReceiveNotificationResponse:withCompletionHandler:)];
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
- (void)rechainUserNotificationCenterDelegate {
|
|
125
|
+
@synchronized(self) {
|
|
126
|
+
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
|
|
127
|
+
id<UNUserNotificationCenterDelegate> currentDelegate = center.delegate;
|
|
128
|
+
|
|
129
|
+
if (currentDelegate == self) {
|
|
130
|
+
[self refreshOriginalDelegateSelectorFlags];
|
|
131
|
+
return;
|
|
66
132
|
}
|
|
67
|
-
|
|
68
|
-
|
|
133
|
+
|
|
134
|
+
self.originalDelegate = currentDelegate;
|
|
135
|
+
[self refreshOriginalDelegateSelectorFlags];
|
|
136
|
+
center.delegate = self;
|
|
137
|
+
}
|
|
69
138
|
}
|
|
70
139
|
|
|
71
140
|
- (void)markInitialNotificationGathered {
|
|
@@ -176,9 +245,11 @@ struct {
|
|
|
176
245
|
}
|
|
177
246
|
|
|
178
247
|
} else if (_originalDelegate != nil && originalUNCDelegateRespondsTo.willPresentNotification) {
|
|
248
|
+
NotifeeCorePresentationCompletionHandler oneShotCompletionHandler =
|
|
249
|
+
NotifeeCoreOneShotPresentationCompletionHandler(completionHandler);
|
|
179
250
|
[_originalDelegate userNotificationCenter:center
|
|
180
251
|
willPresentNotification:notification
|
|
181
|
-
withCompletionHandler:
|
|
252
|
+
withCompletionHandler:oneShotCompletionHandler];
|
|
182
253
|
} else {
|
|
183
254
|
// No original delegate captured and the notification is not Notifee-owned.
|
|
184
255
|
// Returning UNNotificationPresentationOptionNone would silently drop the
|
|
@@ -214,9 +285,11 @@ struct {
|
|
|
214
285
|
// Flag OFF: always forward to original delegate, never parse as Notifee
|
|
215
286
|
if (_originalDelegate != nil &&
|
|
216
287
|
originalUNCDelegateRespondsTo.didReceiveNotificationResponse) {
|
|
288
|
+
NotifeeCoreVoidCompletionHandler oneShotCompletionHandler =
|
|
289
|
+
NotifeeCoreOneShotVoidCompletionHandler(completionHandler);
|
|
217
290
|
[_originalDelegate userNotificationCenter:center
|
|
218
291
|
didReceiveNotificationResponse:response
|
|
219
|
-
withCompletionHandler:
|
|
292
|
+
withCompletionHandler:oneShotCompletionHandler];
|
|
220
293
|
} else {
|
|
221
294
|
completionHandler();
|
|
222
295
|
}
|
|
@@ -224,9 +297,11 @@ struct {
|
|
|
224
297
|
}
|
|
225
298
|
// Flag ON (default): existing behavior
|
|
226
299
|
if (_originalDelegate != nil && originalUNCDelegateRespondsTo.didReceiveNotificationResponse) {
|
|
300
|
+
NotifeeCoreVoidCompletionHandler oneShotCompletionHandler =
|
|
301
|
+
NotifeeCoreOneShotVoidCompletionHandler(completionHandler);
|
|
227
302
|
[_originalDelegate userNotificationCenter:center
|
|
228
303
|
didReceiveNotificationResponse:response
|
|
229
|
-
withCompletionHandler:
|
|
304
|
+
withCompletionHandler:oneShotCompletionHandler];
|
|
230
305
|
return;
|
|
231
306
|
} else {
|
|
232
307
|
notifeeNotification =
|
|
@@ -26,6 +26,10 @@
|
|
|
26
26
|
#import "NotifeeCoreExtensionHelper.h"
|
|
27
27
|
#import "NotifeeCoreUtil.h"
|
|
28
28
|
|
|
29
|
+
@interface NotifeeCoreUNUserNotificationCenter (Rechain)
|
|
30
|
+
- (void)rechainUserNotificationCenterDelegate;
|
|
31
|
+
@end
|
|
32
|
+
|
|
29
33
|
static NSString *const kNotifeeRollingPublicId = @"notifee_rolling_public_id";
|
|
30
34
|
static NSString *const kNotifeeRollingOccurrenceMs = @"notifee_rolling_occurrence_ms";
|
|
31
35
|
static NSString *const kNotifeeRollingInternalId = @"notifee_rolling_internal_id";
|
|
@@ -1140,6 +1144,8 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
1140
1144
|
* @param block notifeeMethodVoidBlock
|
|
1141
1145
|
*/
|
|
1142
1146
|
+ (void)displayNotification:(NSDictionary *)notification withBlock:(notifeeMethodVoidBlock)block {
|
|
1147
|
+
[[NotifeeCoreUNUserNotificationCenter instance] rechainUserNotificationCenterDelegate];
|
|
1148
|
+
|
|
1143
1149
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
1144
1150
|
UNMutableNotificationContent *content = [self buildNotificationContent:notification
|
|
1145
1151
|
withTrigger:nil];
|
|
@@ -1223,6 +1229,8 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
1223
1229
|
+ (void)createTriggerNotification:(NSDictionary *)notification
|
|
1224
1230
|
withTrigger:(NSDictionary *)trigger
|
|
1225
1231
|
withBlock:(notifeeMethodVoidBlock)block {
|
|
1232
|
+
[[NotifeeCoreUNUserNotificationCenter instance] rechainUserNotificationCenterDelegate];
|
|
1233
|
+
|
|
1226
1234
|
dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
|
|
1227
1235
|
UNMutableNotificationContent *content =
|
|
1228
1236
|
[self triggerNotificationContentForNotification:notification trigger:trigger];
|
|
@@ -1543,6 +1551,8 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
1543
1551
|
*/
|
|
1544
1552
|
+ (void)requestPermission:(NSDictionary *)permissions
|
|
1545
1553
|
withBlock:(notifeeMethodNSDictionaryBlock)block {
|
|
1554
|
+
[[NotifeeCoreUNUserNotificationCenter instance] rechainUserNotificationCenterDelegate];
|
|
1555
|
+
|
|
1546
1556
|
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
|
|
1547
1557
|
|
|
1548
1558
|
UNAuthorizationOptions options = UNAuthorizationOptionNone;
|
|
@@ -1678,6 +1688,8 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
1678
1688
|
}
|
|
1679
1689
|
|
|
1680
1690
|
+ (void)getInitialNotification:(notifeeMethodNSDictionaryBlock)block {
|
|
1691
|
+
[[NotifeeCoreUNUserNotificationCenter instance] rechainUserNotificationCenterDelegate];
|
|
1692
|
+
|
|
1681
1693
|
[NotifeeCoreUNUserNotificationCenter instance].initialNotificationBlock = block;
|
|
1682
1694
|
[[NotifeeCoreUNUserNotificationCenter instance] getInitialNotification];
|
|
1683
1695
|
}
|
|
@@ -1784,6 +1796,7 @@ typedef NS_ENUM(NSInteger, NotifeeCoreRollingErrorCode) {
|
|
|
1784
1796
|
[NotifeeCoreUNUserNotificationCenter instance].shouldHandleRemoteNotifications =
|
|
1785
1797
|
[config[@"ios"][@"handleRemoteNotifications"] boolValue];
|
|
1786
1798
|
}
|
|
1799
|
+
[[NotifeeCoreUNUserNotificationCenter instance] rechainUserNotificationCenterDelegate];
|
|
1787
1800
|
block(nil);
|
|
1788
1801
|
}
|
|
1789
1802
|
|
|
@@ -18,6 +18,11 @@
|
|
|
18
18
|
#import "NotifeeApiModule.h"
|
|
19
19
|
#import <React/RCTUtils.h>
|
|
20
20
|
#import <UIKit/UIKit.h>
|
|
21
|
+
#import "NotifeeCore+UNUserNotificationCenter.h"
|
|
22
|
+
|
|
23
|
+
@interface NotifeeCoreUNUserNotificationCenter (Rechain)
|
|
24
|
+
- (void)rechainUserNotificationCenterDelegate;
|
|
25
|
+
@end
|
|
21
26
|
|
|
22
27
|
static NSString *kReactNativeNotifeeNotificationEvent = @"app.notifee.notification-event";
|
|
23
28
|
static NSString *kReactNativeNotifeeNotificationBackgroundEvent =
|
|
@@ -56,6 +61,8 @@ RCT_EXPORT_MODULE();
|
|
|
56
61
|
}
|
|
57
62
|
|
|
58
63
|
- (void)startObserving {
|
|
64
|
+
[[NotifeeCoreUNUserNotificationCenter instance] rechainUserNotificationCenterDelegate];
|
|
65
|
+
|
|
59
66
|
NSArray *eventsToFlush;
|
|
60
67
|
@synchronized(self) {
|
|
61
68
|
hasListeners = YES;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-notify-kit",
|
|
3
|
-
"version": "10.3.
|
|
3
|
+
"version": "10.3.3",
|
|
4
4
|
"author": "Marco Crupi",
|
|
5
5
|
"description": "Maintained Notifee-compatible fork for React Native — advanced local notifications for Android & iOS.",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"build:watch": "tsc --watch",
|
|
31
31
|
"test:server": "jest --config jest.config.server.js",
|
|
32
32
|
"prepare": "yarn run build",
|
|
33
|
-
"prepack": "bash
|
|
33
|
+
"prepack": "cd ../.. && bash build_ios_core.sh && bash scripts/verify-ios-core-generation.sh && bash scripts/prepack-cli.sh",
|
|
34
34
|
"postpack": "rm -rf cli",
|
|
35
35
|
"prepublishOnly": "cd ../.. && yarn run build:core",
|
|
36
36
|
"format:android": "google-java-format --replace -i $(find . -type f -name \"*.java\" ! -path \"*/node_modules/*\" ! -path \"*/generated/*\")",
|
package/src/version.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
// Generated by genversion.
|
|
2
|
-
export const version = '10.3.
|
|
2
|
+
export const version = '10.3.3';
|