@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.
Files changed (38) hide show
  1. package/android/build.gradle +8 -2
  2. package/android/src/main/java/com/courierreactnative/CourierSharedModule.kt +43 -40
  3. package/android/src/main/java/com/courierreactnative/Utils.kt +1 -1
  4. package/courier-react-native.podspec +2 -2
  5. package/ios/CourierReactNativeDelegate.m +2 -6
  6. package/ios/CourierReactNativeEventEmitter.swift +1 -1
  7. package/ios/CourierReactNativeModule.m +53 -19
  8. package/ios/CourierSharedModule.swift +298 -267
  9. package/ios/Utils.swift +3 -1
  10. package/lib/commonjs/Broadcaster.js +3 -1
  11. package/lib/commonjs/Broadcaster.js.map +1 -1
  12. package/lib/commonjs/index.js +52 -50
  13. package/lib/commonjs/index.js.map +1 -1
  14. package/lib/commonjs/models/CourierAuthenticationListener.js +2 -2
  15. package/lib/commonjs/models/CourierAuthenticationListener.js.map +1 -1
  16. package/lib/commonjs/models/CourierInboxListener.js +2 -2
  17. package/lib/commonjs/models/CourierInboxListener.js.map +1 -1
  18. package/lib/module/Broadcaster.js +3 -1
  19. package/lib/module/Broadcaster.js.map +1 -1
  20. package/lib/module/index.js +52 -50
  21. package/lib/module/index.js.map +1 -1
  22. package/lib/module/models/CourierAuthenticationListener.js +2 -2
  23. package/lib/module/models/CourierAuthenticationListener.js.map +1 -1
  24. package/lib/module/models/CourierInboxListener.js +2 -2
  25. package/lib/module/models/CourierInboxListener.js.map +1 -1
  26. package/lib/typescript/src/Broadcaster.d.ts +1 -1
  27. package/lib/typescript/src/Broadcaster.d.ts.map +1 -1
  28. package/lib/typescript/src/index.d.ts +21 -20
  29. package/lib/typescript/src/index.d.ts.map +1 -1
  30. package/lib/typescript/src/models/CourierAuthenticationListener.d.ts +1 -1
  31. package/lib/typescript/src/models/CourierAuthenticationListener.d.ts.map +1 -1
  32. package/lib/typescript/src/models/CourierInboxListener.d.ts +1 -1
  33. package/lib/typescript/src/models/CourierInboxListener.d.ts.map +1 -1
  34. package/package.json +1 -1
  35. package/src/Broadcaster.tsx +4 -1
  36. package/src/index.tsx +68 -62
  37. package/src/models/CourierAuthenticationListener.tsx +2 -2
  38. package/src/models/CourierInboxListener.tsx +2 -2
@@ -8,7 +8,7 @@ buildscript {
8
8
  }
9
9
 
10
10
  dependencies {
11
- classpath "com.android.tools.build:gradle:8.1.4"
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.0.2'
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(isBlockingSynchronousMethod = true)
58
- fun getClient(): String? {
59
- val options = Courier.shared.client?.options ?: return null
60
- return options.toJson()
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(isBlockingSynchronousMethod = true)
66
- fun getUserId(): String? {
67
- return Courier.shared.userId
69
+ @ReactMethod
70
+ fun getUserId(promise: Promise) {
71
+ promise.resolve(Courier.shared.userId)
68
72
  }
69
73
 
70
- @ReactMethod(isBlockingSynchronousMethod = true)
71
- fun getTenantId(): String? {
72
- return Courier.shared.tenantId
74
+ @ReactMethod
75
+ fun getTenantId(promise: Promise) {
76
+ promise.resolve(Courier.shared.tenantId)
73
77
  }
74
78
 
75
- @ReactMethod(isBlockingSynchronousMethod = true)
76
- fun getIsUserSignedIn(): String {
77
- return Courier.shared.isUserSignedIn.toString()
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(isBlockingSynchronousMethod = true)
99
- fun addAuthenticationListener(listenerId: String): 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
- return listenerId
116
+ promise.resolve(listenerId)
113
117
 
114
118
  }
115
119
 
116
- @ReactMethod(isBlockingSynchronousMethod = true)
117
- fun removeAuthenticationListener(listenerId: String): 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
- return listenerId
131
+ promise.resolve(listenerId)
128
132
 
129
133
  }
130
134
 
131
- @ReactMethod(isBlockingSynchronousMethod = true)
132
- fun removeAllAuthenticationListeners(): String? {
135
+ @ReactMethod
136
+ fun removeAllAuthenticationListeners(promise: Promise) {
133
137
  authenticationListeners.values.forEach { it.remove() }
134
138
  authenticationListeners.clear()
135
- return null
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(isBlockingSynchronousMethod = true)
169
- fun getInboxPaginationLimit(): String {
170
- return Courier.shared.inboxPaginationLimit.toString()
172
+ @ReactMethod
173
+ fun getInboxPaginationLimit(promise: Promise) {
174
+ promise.resolve(Courier.shared.inboxPaginationLimit.toString())
171
175
  }
172
176
 
173
- @ReactMethod(isBlockingSynchronousMethod = true)
174
- fun setInboxPaginationLimit(limit: Double): String {
177
+ @ReactMethod
178
+ fun setInboxPaginationLimit(limit: Double, promise: Promise) {
175
179
  Courier.shared.inboxPaginationLimit = limit.toInt()
176
- return Courier.shared.inboxPaginationLimit.toString()
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(isBlockingSynchronousMethod = true)
240
- fun addInboxListener(loadingId: String, errorId: String, unreadCountId: String, feedId: String, archiveId: String, pageAddedId: String, messageChangedId: String, messageAddedId: String, messageRemovedId: String): 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
- val id = UUID.randomUUID().toString()
318
- inboxListeners[id] = listener
321
+ inboxListeners[listenerId] = listener
319
322
 
320
- return id
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(isBlockingSynchronousMethod = true)
333
- fun removeInboxListener(listenerId: String): 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
- return listenerId
340
+ promise.resolve(listenerId)
338
341
  }
339
342
 
340
- @ReactMethod(isBlockingSynchronousMethod = true)
341
- fun removeAllInboxListeners(): String? {
343
+ @ReactMethod
344
+ fun removeAllInboxListeners(promise: Promise) {
342
345
  inboxListeners.values.forEach { it.remove() }
343
346
  inboxListeners.clear()
344
- return null
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.3")
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 => "13.0" }
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.3.2"
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.3"];
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
- [[Courier shared] setAPNSTokenWithRawToken:deviceToken completion:^(NSError * _Nullable error) {
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.3")
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
- getClient
6
+ addEmitter:(NSString *)emitterId
7
7
  )
8
8
 
9
- RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(
10
- getUserId
9
+ RCT_EXTERN_METHOD(
10
+ attachEmitter: (NSString*)emitterId
11
+ withResolver: (RCTPromiseResolveBlock)resolve
12
+ withRejecter: (RCTPromiseRejectBlock)reject
11
13
  )
12
14
 
13
- RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(
14
- getTenantId
15
+ RCT_EXTERN_METHOD(
16
+ getClient: (RCTPromiseResolveBlock)resolve
17
+ withRejecter: (RCTPromiseRejectBlock)reject
15
18
  )
16
19
 
17
- RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(
18
- getIsUserSignedIn
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
- RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(
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
- RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(
62
+ RCT_EXTERN_METHOD(
41
63
  removeAuthenticationListener: (NSString*)listenerId
64
+ withResolver: (RCTPromiseResolveBlock)resolve
65
+ withRejecter: (RCTPromiseRejectBlock)reject
42
66
  )
43
67
 
44
- RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(
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
- RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(
67
- getInboxPaginationLimit
91
+ RCT_EXTERN_METHOD(
92
+ getInboxPaginationLimit: (RCTPromiseResolveBlock)resolve
93
+ withRejecter: (RCTPromiseRejectBlock)reject
68
94
  )
69
95
 
70
- RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(
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
- RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(
110
- addInboxListener: (NSString*)loadingId
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
- RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(
152
+ RCT_EXTERN_METHOD(
122
153
  removeInboxListener: (NSString*)listenerId
154
+ withResolver: (RCTPromiseResolveBlock)resolve
155
+ withRejecter: (RCTPromiseRejectBlock)reject
123
156
  )
124
157
 
125
- RCT_EXTERN__BLOCKING_SYNCHRONOUS_METHOD(
126
- removeAllInboxListeners
158
+ RCT_EXTERN_METHOD(
159
+ removeAllInboxListeners: (RCTPromiseResolveBlock)resolve
160
+ withRejecter: (RCTPromiseRejectBlock)reject
127
161
  )
128
162
 
129
163
  RCT_EXTERN_METHOD(