@trycourier/courier-react-native 5.5.6 → 5.5.7
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.
|
@@ -15,7 +15,7 @@ import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
|
15
15
|
import com.google.gson.GsonBuilder
|
|
16
16
|
|
|
17
17
|
internal object Utils {
|
|
18
|
-
val COURIER_AGENT = CourierAgent.ReactNativeAndroid(version = "5.5.
|
|
18
|
+
val COURIER_AGENT = CourierAgent.ReactNativeAndroid(version = "5.5.7")
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
internal fun ReactContext.sendEvent(eventName: String, value: Any?) {
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
@import Courier_iOS;
|
|
9
9
|
#import "CourierReactNativeDelegate.h"
|
|
10
|
+
#import <React/RCTRootView.h>
|
|
10
11
|
#import <React/RCTBridge.h>
|
|
11
12
|
#import <React/RCTBridge+Private.h>
|
|
12
13
|
#import <React/RCTUtils.h>
|
|
@@ -17,7 +18,7 @@
|
|
|
17
18
|
@interface CourierReactNativeDelegate ()
|
|
18
19
|
|
|
19
20
|
@property (nonatomic, assign) UNNotificationPresentationOptions notificationPresentationOptions;
|
|
20
|
-
@property (nonatomic, strong) NSDictionary *
|
|
21
|
+
@property (nonatomic, strong) NSDictionary *cachedMessage;
|
|
21
22
|
@property (nonatomic, assign) BOOL isReactNativeReady;
|
|
22
23
|
|
|
23
24
|
@end
|
|
@@ -30,8 +31,9 @@ static NSString *const CourierForegroundOptionsDidChangeNotification = @"iosFore
|
|
|
30
31
|
self = [super init];
|
|
31
32
|
|
|
32
33
|
if (self) {
|
|
34
|
+
|
|
33
35
|
// Set the user agent
|
|
34
|
-
Courier.agent = [CourierAgent reactNativeIOS:@"5.5.
|
|
36
|
+
Courier.agent = [CourierAgent reactNativeIOS:@"5.5.7"];
|
|
35
37
|
|
|
36
38
|
// Register for remote notifications
|
|
37
39
|
UIApplication *app = [UIApplication sharedApplication];
|
|
@@ -40,52 +42,54 @@ static NSString *const CourierForegroundOptionsDidChangeNotification = @"iosFore
|
|
|
40
42
|
// Set notification center delegate
|
|
41
43
|
UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
|
|
42
44
|
center.delegate = self;
|
|
43
|
-
|
|
44
|
-
// Detect JS bridge load
|
|
45
|
-
self.isReactNativeReady = [self detectIfBridgeIsReady];
|
|
46
45
|
|
|
47
46
|
[[NSNotificationCenter defaultCenter]
|
|
48
47
|
addObserver:self
|
|
49
|
-
selector:@selector(
|
|
50
|
-
name:
|
|
48
|
+
selector:@selector(notificationPresentationOptionsUpdate:)
|
|
49
|
+
name:CourierForegroundOptionsDidChangeNotification
|
|
51
50
|
object:nil];
|
|
52
|
-
|
|
51
|
+
|
|
53
52
|
[[NSNotificationCenter defaultCenter]
|
|
54
53
|
addObserver:self
|
|
55
|
-
selector:@selector(
|
|
56
|
-
name:
|
|
54
|
+
selector:@selector(onBridgeWillReload)
|
|
55
|
+
name:RCTBridgeWillReloadNotification
|
|
56
|
+
object:nil];
|
|
57
|
+
|
|
58
|
+
[[NSNotificationCenter defaultCenter]
|
|
59
|
+
addObserver:self
|
|
60
|
+
selector:@selector(onReactUIReady:)
|
|
61
|
+
name:RCTContentDidAppearNotification
|
|
57
62
|
object:nil];
|
|
58
63
|
}
|
|
59
64
|
|
|
60
65
|
return self;
|
|
61
66
|
}
|
|
62
67
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
68
|
+
// Called when React Native is loaded and ready
|
|
69
|
+
- (void)onReactUIReady:(__unused NSNotification *)note
|
|
70
|
+
{
|
|
71
|
+
self.isReactNativeReady = YES;
|
|
72
|
+
|
|
73
|
+
// flush anything that was queued while RN was booting
|
|
74
|
+
if (self.cachedMessage) {
|
|
75
|
+
[[NSNotificationCenter defaultCenter] postNotificationName:@"pushNotificationClicked" object:nil userInfo:self.cachedMessage];
|
|
76
|
+
self.cachedMessage = nil;
|
|
77
|
+
}
|
|
66
78
|
}
|
|
67
79
|
|
|
68
|
-
|
|
80
|
+
// Called when there is a reload to React Native
|
|
81
|
+
- (void)onBridgeWillReload
|
|
69
82
|
{
|
|
70
|
-
|
|
71
|
-
self.notificationPresentationOptions = ((NSNumber *)[userInfo objectForKey:@"options"]).unsignedIntegerValue;
|
|
83
|
+
self.isReactNativeReady = NO;
|
|
72
84
|
}
|
|
73
85
|
|
|
74
|
-
- (void)
|
|
86
|
+
- (void)notificationPresentationOptionsUpdate:(NSNotification *)notification
|
|
75
87
|
{
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
if (self.pendingNotificationClick) {
|
|
79
|
-
[[NSNotificationCenter defaultCenter] postNotificationName:@"pushNotificationClicked"
|
|
80
|
-
object:nil
|
|
81
|
-
userInfo:self.pendingNotificationClick];
|
|
82
|
-
self.pendingNotificationClick = nil;
|
|
83
|
-
}
|
|
88
|
+
NSDictionary *userInfo = notification.userInfo;
|
|
89
|
+
self.notificationPresentationOptions = ((NSNumber *)[userInfo objectForKey:@"options"]).unsignedIntegerValue;
|
|
84
90
|
}
|
|
85
91
|
|
|
86
|
-
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
|
|
87
|
-
didReceiveNotificationResponse:(UNNotificationResponse *)response
|
|
88
|
-
withCompletionHandler:(void (^)(void))completionHandler
|
|
92
|
+
- (void)userNotificationCenter:(UNUserNotificationCenter *)center didReceiveNotificationResponse:(UNNotificationResponse *)response withCompletionHandler:(void (^)(void))completionHandler
|
|
89
93
|
{
|
|
90
94
|
UNNotificationContent *content = response.notification.request.content;
|
|
91
95
|
NSDictionary *message = content.userInfo;
|
|
@@ -97,22 +101,18 @@ didReceiveNotificationResponse:(UNNotificationResponse *)response
|
|
|
97
101
|
}];
|
|
98
102
|
|
|
99
103
|
NSDictionary *pushNotification = [Courier formatPushNotificationWithContent:content];
|
|
100
|
-
|
|
104
|
+
|
|
101
105
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
}
|
|
109
|
-
completionHandler();
|
|
106
|
+
if (self.isReactNativeReady) {
|
|
107
|
+
[[NSNotificationCenter defaultCenter] postNotificationName:@"pushNotificationClicked" object:nil userInfo:pushNotification];
|
|
108
|
+
} else {
|
|
109
|
+
self.cachedMessage = pushNotification;
|
|
110
|
+
}
|
|
111
|
+
completionHandler();
|
|
110
112
|
});
|
|
111
113
|
}
|
|
112
114
|
|
|
113
|
-
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
|
|
114
|
-
willPresentNotification:(UNNotification *)notification
|
|
115
|
-
withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler
|
|
115
|
+
- (void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler
|
|
116
116
|
{
|
|
117
117
|
UNNotificationContent *content = notification.request.content;
|
|
118
118
|
NSDictionary *message = content.userInfo;
|
|
@@ -125,23 +125,25 @@ didReceiveNotificationResponse:(UNNotificationResponse *)response
|
|
|
125
125
|
|
|
126
126
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
127
127
|
NSDictionary *pushNotification = [Courier formatPushNotificationWithContent:content];
|
|
128
|
-
[[NSNotificationCenter defaultCenter] postNotificationName:@"pushNotificationDelivered"
|
|
129
|
-
object:nil
|
|
130
|
-
userInfo:pushNotification];
|
|
128
|
+
[[NSNotificationCenter defaultCenter] postNotificationName:@"pushNotificationDelivered" object:nil userInfo:pushNotification];
|
|
131
129
|
completionHandler(self.notificationPresentationOptions);
|
|
132
130
|
});
|
|
133
131
|
}
|
|
134
132
|
|
|
135
|
-
- (void)application:(UIApplication *)application
|
|
136
|
-
didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
|
|
133
|
+
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
|
|
137
134
|
{
|
|
138
135
|
NSLog(@"[Courier] Failed to register for remote notifications: %@", error.localizedDescription);
|
|
139
136
|
}
|
|
140
137
|
|
|
141
|
-
- (void)application:(UIApplication *)application
|
|
142
|
-
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
|
|
138
|
+
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
|
|
143
139
|
{
|
|
144
140
|
[Courier setAPNSToken:deviceToken];
|
|
145
141
|
}
|
|
146
142
|
|
|
143
|
+
- (void)dealloc
|
|
144
|
+
{
|
|
145
|
+
self.cachedMessage = nil;
|
|
146
|
+
self.isReactNativeReady = NO;
|
|
147
|
+
}
|
|
148
|
+
|
|
147
149
|
@end
|
|
@@ -14,7 +14,7 @@ internal class CourierReactNativeEventEmitter: RCTEventEmitter {
|
|
|
14
14
|
|
|
15
15
|
// Set the user agent
|
|
16
16
|
// Used to know the platform performing requests
|
|
17
|
-
Courier.agent = CourierAgent.reactNativeIOS("5.5.
|
|
17
|
+
Courier.agent = CourierAgent.reactNativeIOS("5.5.7")
|
|
18
18
|
|
|
19
19
|
}
|
|
20
20
|
|