@trycourier/courier-react-native 5.5.3 → 5.5.4
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.
|
@@ -22,7 +22,7 @@ class CourierSystemModule(reactContext: ReactApplicationContext): ReactNativeMod
|
|
|
22
22
|
|
|
23
23
|
init {
|
|
24
24
|
|
|
25
|
-
//
|
|
25
|
+
// Listen to push notification events
|
|
26
26
|
Courier.shared.onPushNotificationEvent { event ->
|
|
27
27
|
when (event.trackingEvent) {
|
|
28
28
|
CLICKED -> postPushNotificationJavascriptEvent(CourierEvents.Push.CLICKED_EVENT, event.remoteMessage)
|
|
@@ -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.4")
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
internal fun ReactContext.sendEvent(eventName: String, value: Any?) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// CourierReactNativeDelegate.m
|
|
3
3
|
// courier-react-native
|
|
4
4
|
//
|
|
5
|
-
// Created by
|
|
5
|
+
// Created by https://github.com/mikemilla on 10/7/22.
|
|
6
6
|
//
|
|
7
7
|
|
|
8
8
|
@import Courier_iOS;
|
|
@@ -12,21 +12,20 @@
|
|
|
12
12
|
|
|
13
13
|
@interface CourierReactNativeDelegate ()
|
|
14
14
|
|
|
15
|
-
@property (nonatomic, copy) NSString *iosForegroundNotificationPresentationOptions;
|
|
16
15
|
@property (nonatomic, assign) UNNotificationPresentationOptions notificationPresentationOptions;
|
|
17
16
|
|
|
18
17
|
@end
|
|
19
18
|
|
|
20
19
|
@implementation CourierReactNativeDelegate
|
|
21
20
|
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
static NSString *const CourierForegroundOptionsDidChangeNotification = @"iosForegroundNotificationPresentationOptions";
|
|
22
|
+
|
|
23
|
+
- (id)init {
|
|
24
24
|
self = [super init];
|
|
25
25
|
|
|
26
26
|
if (self) {
|
|
27
|
-
|
|
28
27
|
// Set the user agent
|
|
29
|
-
Courier.agent = [CourierAgent reactNativeIOS:@"5.5.
|
|
28
|
+
Courier.agent = [CourierAgent reactNativeIOS:@"5.5.4"];
|
|
30
29
|
|
|
31
30
|
// Register for remote notifications
|
|
32
31
|
UIApplication *app = [UIApplication sharedApplication];
|
|
@@ -39,28 +38,27 @@
|
|
|
39
38
|
[[NSNotificationCenter defaultCenter]
|
|
40
39
|
addObserver:self
|
|
41
40
|
selector:@selector(notificationPresentationOptionsUpdate:)
|
|
42
|
-
name:
|
|
41
|
+
name:CourierForegroundOptionsDidChangeNotification
|
|
43
42
|
object:nil
|
|
44
43
|
];
|
|
45
|
-
|
|
46
44
|
}
|
|
47
45
|
|
|
48
|
-
return
|
|
49
|
-
|
|
46
|
+
return self;
|
|
50
47
|
}
|
|
51
48
|
|
|
52
|
-
- (void)
|
|
49
|
+
- (void)notificationPresentationOptionsUpdate:(NSNotification *)notification
|
|
53
50
|
{
|
|
54
|
-
if ([[notification name] isEqualToString:
|
|
51
|
+
if ([[notification name] isEqualToString:CourierForegroundOptionsDidChangeNotification])
|
|
55
52
|
{
|
|
56
53
|
NSDictionary *userInfo = notification.userInfo;
|
|
57
|
-
|
|
54
|
+
self.notificationPresentationOptions = ((NSNumber *)[userInfo objectForKey:@"options"]).unsignedIntegerValue;
|
|
58
55
|
}
|
|
59
56
|
}
|
|
60
57
|
|
|
61
|
-
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
|
|
58
|
+
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
|
|
59
|
+
willPresentNotification:(UNNotification *)notification
|
|
60
|
+
withCompletionHandler:(void (^)(UNNotificationPresentationOptions))completionHandler
|
|
62
61
|
{
|
|
63
|
-
|
|
64
62
|
UNNotificationContent *content = notification.request.content;
|
|
65
63
|
NSDictionary *message = content.userInfo;
|
|
66
64
|
|
|
@@ -71,19 +69,16 @@
|
|
|
71
69
|
}];
|
|
72
70
|
|
|
73
71
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
74
|
-
|
|
75
72
|
NSDictionary *pushNotification = [Courier formatPushNotificationWithContent:content];
|
|
76
73
|
[[NSNotificationCenter defaultCenter] postNotificationName:@"pushNotificationDelivered" object:nil userInfo:pushNotification];
|
|
77
|
-
|
|
78
|
-
completionHandler(self->_notificationPresentationOptions);
|
|
79
|
-
|
|
74
|
+
completionHandler(self.notificationPresentationOptions);
|
|
80
75
|
});
|
|
81
|
-
|
|
82
76
|
}
|
|
83
77
|
|
|
84
|
-
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
|
|
78
|
+
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
|
|
79
|
+
didReceiveNotificationResponse:(UNNotificationResponse *)response
|
|
80
|
+
withCompletionHandler:(void (^)(void))completionHandler
|
|
85
81
|
{
|
|
86
|
-
|
|
87
82
|
UNNotificationContent *content = response.notification.request.content;
|
|
88
83
|
NSDictionary *message = content.userInfo;
|
|
89
84
|
|
|
@@ -94,22 +89,20 @@
|
|
|
94
89
|
}];
|
|
95
90
|
|
|
96
91
|
dispatch_async(dispatch_get_main_queue(), ^{
|
|
97
|
-
|
|
98
92
|
NSDictionary *pushNotification = [Courier formatPushNotificationWithContent:content];
|
|
99
93
|
[[NSNotificationCenter defaultCenter] postNotificationName:@"pushNotificationClicked" object:nil userInfo:pushNotification];
|
|
100
|
-
|
|
101
94
|
completionHandler();
|
|
102
|
-
|
|
103
95
|
});
|
|
104
|
-
|
|
105
96
|
}
|
|
106
97
|
|
|
107
|
-
- (void)application:(UIApplication *)application
|
|
98
|
+
- (void)application:(UIApplication *)application
|
|
99
|
+
didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
|
|
108
100
|
{
|
|
109
|
-
NSLog(@"Failed to
|
|
101
|
+
NSLog(@"Failed to register for remote notification token: %@", error.localizedDescription);
|
|
110
102
|
}
|
|
111
103
|
|
|
112
|
-
- (void)application:(UIApplication *)application
|
|
104
|
+
- (void)application:(UIApplication *)application
|
|
105
|
+
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
|
|
113
106
|
{
|
|
114
107
|
[Courier setAPNSToken:deviceToken];
|
|
115
108
|
}
|
|
@@ -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.4")
|
|
18
18
|
|
|
19
19
|
}
|
|
20
20
|
|