@trycourier/courier-react-native 5.2.3 → 5.3.2
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/android/build.gradle +8 -2
- package/android/src/main/java/com/courierreactnative/CourierSharedModule.kt +43 -40
- package/android/src/main/java/com/courierreactnative/Utils.kt +1 -1
- package/courier-react-native.podspec +2 -2
- package/ios/CourierReactNativeDelegate.m +2 -6
- package/ios/CourierReactNativeEventEmitter.swift +1 -1
- package/ios/CourierReactNativeModule.m +53 -19
- package/ios/CourierSharedModule.swift +298 -267
- package/ios/Utils.swift +3 -1
- package/lib/commonjs/Broadcaster.js +3 -1
- package/lib/commonjs/Broadcaster.js.map +1 -1
- package/lib/commonjs/index.js +52 -50
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/CourierAuthenticationListener.js +2 -2
- package/lib/commonjs/models/CourierAuthenticationListener.js.map +1 -1
- package/lib/commonjs/models/CourierInboxListener.js +2 -2
- package/lib/commonjs/models/CourierInboxListener.js.map +1 -1
- package/lib/module/Broadcaster.js +3 -1
- package/lib/module/Broadcaster.js.map +1 -1
- package/lib/module/index.js +52 -50
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/CourierAuthenticationListener.js +2 -2
- package/lib/module/models/CourierAuthenticationListener.js.map +1 -1
- package/lib/module/models/CourierInboxListener.js +2 -2
- package/lib/module/models/CourierInboxListener.js.map +1 -1
- package/lib/typescript/src/Broadcaster.d.ts +1 -1
- package/lib/typescript/src/Broadcaster.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +21 -20
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/models/CourierAuthenticationListener.d.ts +1 -1
- package/lib/typescript/src/models/CourierAuthenticationListener.d.ts.map +1 -1
- package/lib/typescript/src/models/CourierInboxListener.d.ts +1 -1
- package/lib/typescript/src/models/CourierInboxListener.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/Broadcaster.tsx +4 -1
- package/src/index.tsx +68 -62
- package/src/models/CourierAuthenticationListener.tsx +2 -2
- package/src/models/CourierInboxListener.tsx +2 -2
package/android/build.gradle
CHANGED
|
@@ -8,7 +8,7 @@ buildscript {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
dependencies {
|
|
11
|
-
classpath "com.android.tools.build:gradle:8.1.
|
|
11
|
+
classpath "com.android.tools.build:gradle:8.1.0"
|
|
12
12
|
// noinspection DifferentKotlinGradleVersion
|
|
13
13
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
14
14
|
}
|
|
@@ -50,6 +50,7 @@ def supportsNamespace() {
|
|
|
50
50
|
}
|
|
51
51
|
|
|
52
52
|
android {
|
|
53
|
+
|
|
53
54
|
if (supportsNamespace()) {
|
|
54
55
|
namespace "com.courierreactnative"
|
|
55
56
|
|
|
@@ -62,11 +63,16 @@ android {
|
|
|
62
63
|
|
|
63
64
|
compileSdkVersion getExtOrIntegerDefault("compileSdkVersion")
|
|
64
65
|
|
|
66
|
+
buildFeatures {
|
|
67
|
+
buildConfig true
|
|
68
|
+
}
|
|
69
|
+
|
|
65
70
|
defaultConfig {
|
|
66
71
|
minSdkVersion getExtOrIntegerDefault("minSdkVersion")
|
|
67
72
|
targetSdkVersion getExtOrIntegerDefault("targetSdkVersion")
|
|
68
73
|
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
|
|
69
74
|
}
|
|
75
|
+
|
|
70
76
|
buildTypes {
|
|
71
77
|
release {
|
|
72
78
|
minifyEnabled false
|
|
@@ -104,7 +110,7 @@ dependencies {
|
|
|
104
110
|
implementation 'com.google.code.gson:gson:2.11.0'
|
|
105
111
|
|
|
106
112
|
// Courier Core SDK
|
|
107
|
-
api 'com.github.trycourier:courier-android:5.
|
|
113
|
+
api 'com.github.trycourier:courier-android:5.1.8'
|
|
108
114
|
api 'androidx.recyclerview:recyclerview:1.3.2'
|
|
109
115
|
|
|
110
116
|
}
|
|
@@ -33,7 +33,6 @@ import com.facebook.react.bridge.WritableMap
|
|
|
33
33
|
import kotlinx.coroutines.CoroutineScope
|
|
34
34
|
import kotlinx.coroutines.Dispatchers
|
|
35
35
|
import kotlinx.coroutines.launch
|
|
36
|
-
import java.util.UUID
|
|
37
36
|
|
|
38
37
|
|
|
39
38
|
class CourierSharedModule(reactContext: ReactApplicationContext): ReactNativeModule(tag = "Shared Instance Error", name = "CourierSharedModule", reactContext = reactContext) {
|
|
@@ -52,29 +51,34 @@ class CourierSharedModule(reactContext: ReactApplicationContext): ReactNativeMod
|
|
|
52
51
|
// Keep: Required for RN built in Event Emitter Calls.
|
|
53
52
|
}
|
|
54
53
|
|
|
54
|
+
@ReactMethod
|
|
55
|
+
fun attachEmitter(emitterId: String, promise: Promise) {
|
|
56
|
+
promise.resolve(emitterId)
|
|
57
|
+
}
|
|
58
|
+
|
|
55
59
|
// Client
|
|
56
60
|
|
|
57
|
-
@ReactMethod
|
|
58
|
-
fun getClient(
|
|
59
|
-
val options = Courier.shared.client?.options
|
|
60
|
-
|
|
61
|
+
@ReactMethod
|
|
62
|
+
fun getClient(promise: Promise) {
|
|
63
|
+
val options = Courier.shared.client?.options
|
|
64
|
+
promise.resolve(options?.toJson())
|
|
61
65
|
}
|
|
62
66
|
|
|
63
67
|
// Authentication
|
|
64
68
|
|
|
65
|
-
@ReactMethod
|
|
66
|
-
fun getUserId(
|
|
67
|
-
|
|
69
|
+
@ReactMethod
|
|
70
|
+
fun getUserId(promise: Promise) {
|
|
71
|
+
promise.resolve(Courier.shared.userId)
|
|
68
72
|
}
|
|
69
73
|
|
|
70
|
-
@ReactMethod
|
|
71
|
-
fun getTenantId(
|
|
72
|
-
|
|
74
|
+
@ReactMethod
|
|
75
|
+
fun getTenantId(promise: Promise) {
|
|
76
|
+
promise.resolve(Courier.shared.tenantId)
|
|
73
77
|
}
|
|
74
78
|
|
|
75
|
-
@ReactMethod
|
|
76
|
-
fun getIsUserSignedIn(
|
|
77
|
-
|
|
79
|
+
@ReactMethod
|
|
80
|
+
fun getIsUserSignedIn(promise: Promise) {
|
|
81
|
+
promise.resolve(Courier.shared.isUserSignedIn.toString())
|
|
78
82
|
}
|
|
79
83
|
|
|
80
84
|
@ReactMethod
|
|
@@ -95,8 +99,8 @@ class CourierSharedModule(reactContext: ReactApplicationContext): ReactNativeMod
|
|
|
95
99
|
promise.resolve(null)
|
|
96
100
|
}
|
|
97
101
|
|
|
98
|
-
@ReactMethod
|
|
99
|
-
fun addAuthenticationListener(listenerId: String
|
|
102
|
+
@ReactMethod
|
|
103
|
+
fun addAuthenticationListener(listenerId: String, promise: Promise) {
|
|
100
104
|
|
|
101
105
|
// Create the listener
|
|
102
106
|
val listener = Courier.shared.addAuthenticationListener { userId ->
|
|
@@ -109,12 +113,12 @@ class CourierSharedModule(reactContext: ReactApplicationContext): ReactNativeMod
|
|
|
109
113
|
// Add the listener to the map
|
|
110
114
|
authenticationListeners[listenerId] = listener
|
|
111
115
|
|
|
112
|
-
|
|
116
|
+
promise.resolve(listenerId)
|
|
113
117
|
|
|
114
118
|
}
|
|
115
119
|
|
|
116
|
-
@ReactMethod
|
|
117
|
-
fun removeAuthenticationListener(listenerId: String
|
|
120
|
+
@ReactMethod
|
|
121
|
+
fun removeAuthenticationListener(listenerId: String, promise: Promise) {
|
|
118
122
|
|
|
119
123
|
val listener = authenticationListeners[listenerId]
|
|
120
124
|
|
|
@@ -124,15 +128,15 @@ class CourierSharedModule(reactContext: ReactApplicationContext): ReactNativeMod
|
|
|
124
128
|
// Remove the id from the map
|
|
125
129
|
authenticationListeners.remove(listenerId)
|
|
126
130
|
|
|
127
|
-
|
|
131
|
+
promise.resolve(listenerId)
|
|
128
132
|
|
|
129
133
|
}
|
|
130
134
|
|
|
131
|
-
@ReactMethod
|
|
132
|
-
fun removeAllAuthenticationListeners(
|
|
135
|
+
@ReactMethod
|
|
136
|
+
fun removeAllAuthenticationListeners(promise: Promise) {
|
|
133
137
|
authenticationListeners.values.forEach { it.remove() }
|
|
134
138
|
authenticationListeners.clear()
|
|
135
|
-
|
|
139
|
+
promise.resolve(null)
|
|
136
140
|
}
|
|
137
141
|
|
|
138
142
|
// Push
|
|
@@ -165,15 +169,15 @@ class CourierSharedModule(reactContext: ReactApplicationContext): ReactNativeMod
|
|
|
165
169
|
|
|
166
170
|
// Inbox
|
|
167
171
|
|
|
168
|
-
@ReactMethod
|
|
169
|
-
fun getInboxPaginationLimit(
|
|
170
|
-
|
|
172
|
+
@ReactMethod
|
|
173
|
+
fun getInboxPaginationLimit(promise: Promise) {
|
|
174
|
+
promise.resolve(Courier.shared.inboxPaginationLimit.toString())
|
|
171
175
|
}
|
|
172
176
|
|
|
173
|
-
@ReactMethod
|
|
174
|
-
fun setInboxPaginationLimit(limit: Double
|
|
177
|
+
@ReactMethod
|
|
178
|
+
fun setInboxPaginationLimit(limit: Double, promise: Promise) {
|
|
175
179
|
Courier.shared.inboxPaginationLimit = limit.toInt()
|
|
176
|
-
|
|
180
|
+
promise.resolve(Courier.shared.inboxPaginationLimit.toString())
|
|
177
181
|
}
|
|
178
182
|
|
|
179
183
|
@ReactMethod
|
|
@@ -236,8 +240,8 @@ class CourierSharedModule(reactContext: ReactApplicationContext): ReactNativeMod
|
|
|
236
240
|
}
|
|
237
241
|
}
|
|
238
242
|
|
|
239
|
-
@ReactMethod
|
|
240
|
-
fun addInboxListener(loadingId: String, errorId: String, unreadCountId: String, feedId: String, archiveId: String, pageAddedId: String, messageChangedId: String, messageAddedId: String, messageRemovedId: String
|
|
243
|
+
@ReactMethod
|
|
244
|
+
fun addInboxListener(listenerId: String, loadingId: String, errorId: String, unreadCountId: String, feedId: String, archiveId: String, pageAddedId: String, messageChangedId: String, messageAddedId: String, messageRemovedId: String, promise: Promise) {
|
|
241
245
|
|
|
242
246
|
val listener = Courier.shared.addInboxListener(
|
|
243
247
|
onLoading = {
|
|
@@ -314,10 +318,9 @@ class CourierSharedModule(reactContext: ReactApplicationContext): ReactNativeMod
|
|
|
314
318
|
)
|
|
315
319
|
|
|
316
320
|
// Add listener
|
|
317
|
-
|
|
318
|
-
inboxListeners[id] = listener
|
|
321
|
+
inboxListeners[listenerId] = listener
|
|
319
322
|
|
|
320
|
-
|
|
323
|
+
promise.resolve(listenerId)
|
|
321
324
|
|
|
322
325
|
}
|
|
323
326
|
|
|
@@ -329,19 +332,19 @@ class CourierSharedModule(reactContext: ReactApplicationContext): ReactNativeMod
|
|
|
329
332
|
return json
|
|
330
333
|
}
|
|
331
334
|
|
|
332
|
-
@ReactMethod
|
|
333
|
-
fun removeInboxListener(listenerId: String
|
|
335
|
+
@ReactMethod
|
|
336
|
+
fun removeInboxListener(listenerId: String, promise: Promise) {
|
|
334
337
|
val listener = inboxListeners[listenerId]
|
|
335
338
|
listener?.remove()
|
|
336
339
|
inboxListeners.remove(listenerId)
|
|
337
|
-
|
|
340
|
+
promise.resolve(listenerId)
|
|
338
341
|
}
|
|
339
342
|
|
|
340
|
-
@ReactMethod
|
|
341
|
-
fun removeAllInboxListeners(
|
|
343
|
+
@ReactMethod
|
|
344
|
+
fun removeAllInboxListeners(promise: Promise) {
|
|
342
345
|
inboxListeners.values.forEach { it.remove() }
|
|
343
346
|
inboxListeners.clear()
|
|
344
|
-
|
|
347
|
+
promise.resolve(null)
|
|
345
348
|
}
|
|
346
349
|
|
|
347
350
|
@ReactMethod
|
|
@@ -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.2
|
|
18
|
+
val COURIER_AGENT = CourierAgent.ReactNativeAndroid(version = "5.3.2")
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
internal fun ReactContext.sendEvent(eventName: String, value: Any?) {
|
|
@@ -11,13 +11,13 @@ Pod::Spec.new do |s|
|
|
|
11
11
|
s.license = package["license"]
|
|
12
12
|
s.authors = package["author"]
|
|
13
13
|
|
|
14
|
-
s.platforms = { :ios => "
|
|
14
|
+
s.platforms = { :ios => "15.0" }
|
|
15
15
|
s.source = { :git => "https://github.com/trycourier/courier-react-native.git", :tag => "#{s.version}" }
|
|
16
16
|
|
|
17
17
|
s.source_files = "ios/**/*.{h,m,mm,swift}"
|
|
18
18
|
|
|
19
19
|
# Courier Core Dependency
|
|
20
|
-
s.dependency "Courier_iOS", "5.
|
|
20
|
+
s.dependency "Courier_iOS", "5.5.5"
|
|
21
21
|
|
|
22
22
|
# Use install_modules_dependencies helper to install the dependencies if React Native version >=0.71.0.
|
|
23
23
|
# See https://github.com/facebook/react-native/blob/febf6b7f33fdb4904669f99d795eba4c0f95d7bf/scripts/cocoapods/new_architecture.rb#L79.
|
|
@@ -22,7 +22,7 @@ NSUInteger notificationPresentationOptions = UNNotificationPresentationOptionNon
|
|
|
22
22
|
if (self) {
|
|
23
23
|
|
|
24
24
|
// Set the user agent
|
|
25
|
-
Courier.agent = [CourierAgent reactNativeIOS:@"5.2
|
|
25
|
+
Courier.agent = [CourierAgent reactNativeIOS:@"5.3.2"];
|
|
26
26
|
|
|
27
27
|
// Register for remote notifications
|
|
28
28
|
UIApplication *app = [UIApplication sharedApplication];
|
|
@@ -107,11 +107,7 @@ NSUInteger notificationPresentationOptions = UNNotificationPresentationOptionNon
|
|
|
107
107
|
|
|
108
108
|
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
|
|
109
109
|
{
|
|
110
|
-
[
|
|
111
|
-
if (error) {
|
|
112
|
-
NSLog(@"Error setting APNS Token: %@", error.localizedDescription);
|
|
113
|
-
}
|
|
114
|
-
}];
|
|
110
|
+
[Courier setAPNSToken:deviceToken];
|
|
115
111
|
}
|
|
116
112
|
|
|
117
113
|
@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.2
|
|
17
|
+
Courier.agent = CourierAgent.reactNativeIOS("5.3.2")
|
|
18
18
|
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -3,19 +3,33 @@
|
|
|
3
3
|
@interface RCT_EXTERN_MODULE(CourierSharedModule, NSObject)
|
|
4
4
|
|
|
5
5
|
RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(
|
|
6
|
-
|
|
6
|
+
addEmitter:(NSString *)emitterId
|
|
7
7
|
)
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
RCT_EXTERN_METHOD(
|
|
10
|
+
attachEmitter: (NSString*)emitterId
|
|
11
|
+
withResolver: (RCTPromiseResolveBlock)resolve
|
|
12
|
+
withRejecter: (RCTPromiseRejectBlock)reject
|
|
11
13
|
)
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
+
RCT_EXTERN_METHOD(
|
|
16
|
+
getClient: (RCTPromiseResolveBlock)resolve
|
|
17
|
+
withRejecter: (RCTPromiseRejectBlock)reject
|
|
15
18
|
)
|
|
16
19
|
|
|
17
|
-
|
|
18
|
-
|
|
20
|
+
RCT_EXTERN_METHOD(
|
|
21
|
+
getUserId: (RCTPromiseResolveBlock)resolve
|
|
22
|
+
withRejecter: (RCTPromiseRejectBlock)reject
|
|
23
|
+
)
|
|
24
|
+
|
|
25
|
+
RCT_EXTERN_METHOD(
|
|
26
|
+
getTenantId: (RCTPromiseResolveBlock)resolve
|
|
27
|
+
withRejecter: (RCTPromiseRejectBlock)reject
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
RCT_EXTERN_METHOD(
|
|
31
|
+
getIsUserSignedIn: (RCTPromiseResolveBlock)resolve
|
|
32
|
+
withRejecter: (RCTPromiseRejectBlock)reject
|
|
19
33
|
)
|
|
20
34
|
|
|
21
35
|
RCT_EXTERN_METHOD(
|
|
@@ -33,16 +47,27 @@ RCT_EXTERN_METHOD(
|
|
|
33
47
|
withRejecter: (RCTPromiseRejectBlock)reject
|
|
34
48
|
)
|
|
35
49
|
|
|
36
|
-
|
|
50
|
+
RCT_EXTERN_METHOD(
|
|
51
|
+
addAuthenticationListener: (NSString*)listenerId
|
|
52
|
+
withResolver: (RCTPromiseResolveBlock)resolve
|
|
53
|
+
withRejecter: (RCTPromiseRejectBlock)reject
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
RCT_EXTERN_METHOD(
|
|
37
57
|
addAuthenticationListener: (NSString*)authId
|
|
58
|
+
withResolver: (RCTPromiseResolveBlock)resolve
|
|
59
|
+
withRejecter: (RCTPromiseRejectBlock)reject
|
|
38
60
|
)
|
|
39
61
|
|
|
40
|
-
|
|
62
|
+
RCT_EXTERN_METHOD(
|
|
41
63
|
removeAuthenticationListener: (NSString*)listenerId
|
|
64
|
+
withResolver: (RCTPromiseResolveBlock)resolve
|
|
65
|
+
withRejecter: (RCTPromiseRejectBlock)reject
|
|
42
66
|
)
|
|
43
67
|
|
|
44
|
-
|
|
45
|
-
removeAllAuthenticationListeners
|
|
68
|
+
RCT_EXTERN_METHOD(
|
|
69
|
+
removeAllAuthenticationListeners: (RCTPromiseResolveBlock)resolve
|
|
70
|
+
withRejecter: (RCTPromiseRejectBlock)reject
|
|
46
71
|
)
|
|
47
72
|
|
|
48
73
|
RCT_EXTERN_METHOD(
|
|
@@ -63,12 +88,15 @@ RCT_EXTERN_METHOD(
|
|
|
63
88
|
withRejecter: (RCTPromiseRejectBlock)reject
|
|
64
89
|
)
|
|
65
90
|
|
|
66
|
-
|
|
67
|
-
getInboxPaginationLimit
|
|
91
|
+
RCT_EXTERN_METHOD(
|
|
92
|
+
getInboxPaginationLimit: (RCTPromiseResolveBlock)resolve
|
|
93
|
+
withRejecter: (RCTPromiseRejectBlock)reject
|
|
68
94
|
)
|
|
69
95
|
|
|
70
|
-
|
|
96
|
+
RCT_EXTERN_METHOD(
|
|
71
97
|
setInboxPaginationLimit: (double)limit
|
|
98
|
+
withResolver: (RCTPromiseResolveBlock)resolve
|
|
99
|
+
withRejecter: (RCTPromiseRejectBlock)reject
|
|
72
100
|
)
|
|
73
101
|
|
|
74
102
|
RCT_EXTERN_METHOD(
|
|
@@ -106,8 +134,9 @@ RCT_EXTERN_METHOD(
|
|
|
106
134
|
withRejecter: (RCTPromiseRejectBlock)reject
|
|
107
135
|
)
|
|
108
136
|
|
|
109
|
-
|
|
110
|
-
addInboxListener: (NSString*)
|
|
137
|
+
RCT_EXTERN_METHOD(
|
|
138
|
+
addInboxListener: (NSString*)listenerId
|
|
139
|
+
withLoadingId: (NSString*)loadingId
|
|
111
140
|
withErrorId: (NSString*)errorId
|
|
112
141
|
withUnreadCountId: (NSString*)unreadCountId
|
|
113
142
|
withFeedId: (NSString*)feedId
|
|
@@ -116,14 +145,19 @@ RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(
|
|
|
116
145
|
withMessageChangedId: (NSString*)messageChangedId
|
|
117
146
|
withMessageAddedId: (NSString*)messageAddedId
|
|
118
147
|
withMessageRemovedId: (NSString*)messageRemovedId
|
|
148
|
+
withResolver: (RCTPromiseResolveBlock)resolve
|
|
149
|
+
withRejecter: (RCTPromiseRejectBlock)reject
|
|
119
150
|
)
|
|
120
151
|
|
|
121
|
-
|
|
152
|
+
RCT_EXTERN_METHOD(
|
|
122
153
|
removeInboxListener: (NSString*)listenerId
|
|
154
|
+
withResolver: (RCTPromiseResolveBlock)resolve
|
|
155
|
+
withRejecter: (RCTPromiseRejectBlock)reject
|
|
123
156
|
)
|
|
124
157
|
|
|
125
|
-
|
|
126
|
-
removeAllInboxListeners
|
|
158
|
+
RCT_EXTERN_METHOD(
|
|
159
|
+
removeAllInboxListeners: (RCTPromiseResolveBlock)resolve
|
|
160
|
+
withRejecter: (RCTPromiseRejectBlock)reject
|
|
127
161
|
)
|
|
128
162
|
|
|
129
163
|
RCT_EXTERN_METHOD(
|