@trycourier/courier-react-native 5.4.3 → 5.5.1

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 (115) hide show
  1. package/android/build.gradle +2 -2
  2. package/android/gradle.properties +1 -1
  3. package/android/src/main/java/com/courierreactnative/CourierClientModule.kt +298 -303
  4. package/android/src/main/java/com/courierreactnative/CourierSharedModule.kt +194 -165
  5. package/android/src/main/java/com/courierreactnative/Utils.kt +1 -1
  6. package/courier-react-native.podspec +1 -1
  7. package/ios/CourierReactNativeDelegate.m +12 -8
  8. package/ios/CourierReactNativeEventEmitter.swift +1 -1
  9. package/ios/CourierReactNativeModule.m +3 -5
  10. package/ios/CourierSharedModule.swift +88 -112
  11. package/lib/commonjs/index.js +75 -93
  12. package/lib/commonjs/index.js.map +1 -1
  13. package/lib/commonjs/models/CourierInboxListener.js +1 -0
  14. package/lib/commonjs/models/CourierInboxListener.js.map +1 -1
  15. package/lib/commonjs/models/InboxAction.js +22 -0
  16. package/lib/commonjs/models/InboxAction.js.map +1 -1
  17. package/lib/commonjs/models/InboxMessage.js +64 -0
  18. package/lib/commonjs/models/InboxMessage.js.map +1 -1
  19. package/lib/commonjs/models/InboxMessageEvent.js +2 -0
  20. package/lib/commonjs/models/InboxMessageEvent.js.map +1 -0
  21. package/lib/commonjs/views/CourierInboxView.js +6 -4
  22. package/lib/commonjs/views/CourierInboxView.js.map +1 -1
  23. package/lib/example/src/App.js +11 -0
  24. package/lib/example/src/Emitter.js +11 -0
  25. package/lib/example/src/Env.js +6 -0
  26. package/lib/example/src/Home.js +67 -0
  27. package/lib/example/src/Poke.js +75 -0
  28. package/lib/example/src/Tabs.js +36 -0
  29. package/lib/example/src/Utils.js +71 -0
  30. package/lib/example/src/pages/Auth.js +224 -0
  31. package/lib/example/src/pages/Inbox.js +38 -0
  32. package/lib/example/src/pages/Preferences.js +13 -0
  33. package/lib/example/src/pages/PreferencesStack.js +11 -0
  34. package/lib/example/src/pages/Push.js +93 -0
  35. package/lib/example/src/pages/Styles.js +26 -0
  36. package/lib/example/src/pages/Tests.js +1068 -0
  37. package/lib/example/src/pages/inbox/InboxCustom.js +141 -0
  38. package/lib/example/src/pages/inbox/InboxDefault.js +22 -0
  39. package/lib/example/src/pages/inbox/InboxStyled.js +220 -0
  40. package/lib/example/src/pages/preferences/PreferencesCustom.js +91 -0
  41. package/lib/example/src/pages/preferences/PreferencesDefault.js +17 -0
  42. package/lib/example/src/pages/preferences/PreferencesDetail.js +127 -0
  43. package/lib/example/src/pages/preferences/PreferencesStyled.js +110 -0
  44. package/lib/module/index.js +67 -90
  45. package/lib/module/index.js.map +1 -1
  46. package/lib/module/models/CourierInboxListener.js +1 -0
  47. package/lib/module/models/CourierInboxListener.js.map +1 -1
  48. package/lib/module/models/InboxAction.js +16 -1
  49. package/lib/module/models/InboxAction.js.map +1 -1
  50. package/lib/module/models/InboxMessage.js +61 -1
  51. package/lib/module/models/InboxMessage.js.map +1 -1
  52. package/lib/module/models/InboxMessageEvent.js +2 -0
  53. package/lib/module/models/InboxMessageEvent.js.map +1 -0
  54. package/lib/module/views/CourierInboxView.js +6 -4
  55. package/lib/module/views/CourierInboxView.js.map +1 -1
  56. package/lib/package.json +171 -0
  57. package/lib/src/Broadcaster.js +24 -0
  58. package/lib/src/Modules.js +26 -0
  59. package/lib/src/client/BrandClient.js +17 -0
  60. package/lib/src/client/ClientModule.js +14 -0
  61. package/lib/src/client/CourierClient.js +31 -0
  62. package/lib/src/client/InboxClient.js +99 -0
  63. package/lib/src/client/PreferenceClient.js +63 -0
  64. package/lib/src/client/TokenClient.js +27 -0
  65. package/lib/src/client/TrackingClient.js +17 -0
  66. package/lib/src/index.js +567 -0
  67. package/lib/src/models/Android_CourierSheet.js +1 -0
  68. package/lib/src/models/CourierAuthenticationListener.js +14 -0
  69. package/lib/src/models/CourierBrand.js +1 -0
  70. package/lib/src/models/CourierButton.js +1 -0
  71. package/lib/src/models/CourierDevice.js +1 -0
  72. package/lib/src/models/CourierFont.js +1 -0
  73. package/lib/src/models/CourierInboxListener.js +20 -0
  74. package/lib/src/models/CourierInboxMessages.js +1 -0
  75. package/lib/src/models/CourierInboxTheme.js +1 -0
  76. package/lib/src/models/CourierInfoViewStyle.js +1 -0
  77. package/lib/src/models/CourierPaging.js +1 -0
  78. package/lib/src/models/CourierPreferencesTheme.js +1 -0
  79. package/lib/src/models/CourierPushListener.js +14 -0
  80. package/lib/src/models/CourierPushProvider.js +8 -0
  81. package/lib/src/models/CourierTrackingEvent.js +8 -0
  82. package/lib/src/models/CourierUserPreferences.js +51 -0
  83. package/lib/src/models/InboxAction.js +1 -0
  84. package/lib/src/models/InboxMessage.js +1 -0
  85. package/lib/src/models/InboxMessageFeed.js +1 -0
  86. package/lib/src/models/InboxMessageSet.js +1 -0
  87. package/lib/src/models/iOS_CourierCell.js +1 -0
  88. package/lib/src/models/iOS_CourierSheet.js +1 -0
  89. package/lib/src/utils.js +27 -0
  90. package/lib/src/views/CourierInboxView.js +75 -0
  91. package/lib/src/views/CourierPreferencesView.js +33 -0
  92. package/lib/typescript/src/index.d.ts +16 -20
  93. package/lib/typescript/src/index.d.ts.map +1 -1
  94. package/lib/typescript/src/models/CourierInboxListener.d.ts +4 -7
  95. package/lib/typescript/src/models/CourierInboxListener.d.ts.map +1 -1
  96. package/lib/typescript/src/models/InboxAction.d.ts +8 -4
  97. package/lib/typescript/src/models/InboxAction.d.ts.map +1 -1
  98. package/lib/typescript/src/models/InboxMessage.d.ts +28 -14
  99. package/lib/typescript/src/models/InboxMessage.d.ts.map +1 -1
  100. package/lib/typescript/src/models/InboxMessageEvent.d.ts +2 -0
  101. package/lib/typescript/src/models/InboxMessageEvent.d.ts.map +1 -0
  102. package/lib/typescript/src/models/InboxMessageFeed.d.ts +1 -1
  103. package/lib/typescript/src/models/InboxMessageFeed.d.ts.map +1 -1
  104. package/package.json +3 -2
  105. package/src/index.tsx +61 -99
  106. package/src/models/CourierInboxListener.tsx +10 -13
  107. package/src/models/InboxAction.tsx +28 -4
  108. package/src/models/InboxMessage.tsx +102 -14
  109. package/src/models/InboxMessageEvent.tsx +1 -0
  110. package/src/models/InboxMessageFeed.tsx +1 -1
  111. package/src/views/CourierInboxView.tsx +4 -4
  112. package/ios/CourierReactNative.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
  113. package/ios/CourierReactNative.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
  114. package/ios/CourierReactNative.xcodeproj/project.xcworkspace/xcuserdata/mike.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
  115. package/ios/CourierReactNative.xcodeproj/xcuserdata/mike.xcuserdatad/xcschemes/xcschememanagement.plist +0 -14
@@ -34,8 +34,13 @@ import kotlinx.coroutines.CoroutineScope
34
34
  import kotlinx.coroutines.Dispatchers
35
35
  import kotlinx.coroutines.launch
36
36
 
37
-
38
- class CourierSharedModule(reactContext: ReactApplicationContext): ReactNativeModule(tag = "Shared Instance Error", name = "CourierSharedModule", reactContext = reactContext) {
37
+ class CourierSharedModule(
38
+ reactContext: ReactApplicationContext
39
+ ) : ReactNativeModule(
40
+ tag = "Shared Instance Error",
41
+ name = "CourierSharedModule",
42
+ reactContext = reactContext
43
+ ) {
39
44
 
40
45
  // Listeners
41
46
  private var authenticationListeners = mutableMapOf<String, CourierAuthenticationListener>()
@@ -82,26 +87,36 @@ class CourierSharedModule(reactContext: ReactApplicationContext): ReactNativeMod
82
87
  }
83
88
 
84
89
  @ReactMethod
85
- fun signIn(accessToken: String, clientKey: String?, userId: String, tenantId: String?, showLogs: Boolean, promise: Promise) = CoroutineScope(Dispatchers.Main).launch {
86
- Courier.shared.signIn(
87
- userId = userId,
88
- tenantId = tenantId,
89
- accessToken = accessToken,
90
- clientKey = clientKey,
91
- showLogs = showLogs
92
- )
93
- promise.resolve(null)
90
+ fun signIn(
91
+ accessToken: String,
92
+ clientKey: String?,
93
+ userId: String,
94
+ tenantId: String?,
95
+ showLogs: Boolean,
96
+ promise: Promise
97
+ ) {
98
+ CoroutineScope(Dispatchers.Main).launch {
99
+ Courier.shared.signIn(
100
+ userId = userId,
101
+ tenantId = tenantId,
102
+ accessToken = accessToken,
103
+ clientKey = clientKey,
104
+ showLogs = showLogs
105
+ )
106
+ promise.resolve(null)
107
+ }
94
108
  }
95
109
 
96
110
  @ReactMethod
97
- fun signOut(promise: Promise) = CoroutineScope(Dispatchers.Main).launch {
98
- Courier.shared.signOut()
99
- promise.resolve(null)
111
+ fun signOut(promise: Promise) {
112
+ CoroutineScope(Dispatchers.Main).launch {
113
+ Courier.shared.signOut()
114
+ promise.resolve(null)
115
+ }
100
116
  }
101
117
 
102
118
  @ReactMethod
103
119
  fun addAuthenticationListener(listenerId: String, promise: Promise) {
104
-
105
120
  // Create the listener
106
121
  val listener = Courier.shared.addAuthenticationListener { userId ->
107
122
  reactApplicationContext.sendEvent(
@@ -112,24 +127,15 @@ class CourierSharedModule(reactContext: ReactApplicationContext): ReactNativeMod
112
127
 
113
128
  // Add the listener to the map
114
129
  authenticationListeners[listenerId] = listener
115
-
116
130
  promise.resolve(listenerId)
117
-
118
131
  }
119
132
 
120
133
  @ReactMethod
121
134
  fun removeAuthenticationListener(listenerId: String, promise: Promise) {
122
-
123
135
  val listener = authenticationListeners[listenerId]
124
-
125
- // Disable the listener
126
136
  listener?.remove()
127
-
128
- // Remove the id from the map
129
137
  authenticationListeners.remove(listenerId)
130
-
131
138
  promise.resolve(listenerId)
132
-
133
139
  }
134
140
 
135
141
  @ReactMethod
@@ -142,28 +148,34 @@ class CourierSharedModule(reactContext: ReactApplicationContext): ReactNativeMod
142
148
  // Push
143
149
 
144
150
  @ReactMethod
145
- fun getAllTokens(promise: Promise) = CoroutineScope(Dispatchers.Main).launch {
146
- val tokens = Courier.shared.tokens
147
- val resultMap = Arguments.createMap()
148
- tokens.forEach { (key, value) ->
149
- resultMap.putString(key, value)
151
+ fun getAllTokens(promise: Promise) {
152
+ CoroutineScope(Dispatchers.Main).launch {
153
+ val tokens = Courier.shared.tokens
154
+ val resultMap = Arguments.createMap()
155
+ tokens.forEach { (key, value) ->
156
+ resultMap.putString(key, value)
157
+ }
158
+ promise.resolve(resultMap)
150
159
  }
151
- promise.resolve(resultMap)
152
160
  }
153
161
 
154
162
  @ReactMethod
155
- fun getToken(provider: String, promise: Promise) = CoroutineScope(Dispatchers.Main).launch {
156
- val token = Courier.shared.getToken(provider)
157
- promise.resolve(token)
163
+ fun getToken(provider: String, promise: Promise) {
164
+ CoroutineScope(Dispatchers.Main).launch {
165
+ val token = Courier.shared.getToken(provider)
166
+ promise.resolve(token)
167
+ }
158
168
  }
159
169
 
160
170
  @ReactMethod
161
- fun setToken(provider: String, token: String, promise: Promise) = CoroutineScope(Dispatchers.Main).launch {
162
- try {
163
- Courier.shared.setToken(provider, token)
164
- promise.resolve(null)
165
- } catch (e: Exception) {
166
- promise.apiError(e)
171
+ fun setToken(provider: String, token: String, promise: Promise) {
172
+ CoroutineScope(Dispatchers.Main).launch {
173
+ try {
174
+ Courier.shared.setToken(provider, token)
175
+ promise.resolve(null)
176
+ } catch (e: Exception) {
177
+ promise.apiError(e)
178
+ }
167
179
  }
168
180
  }
169
181
 
@@ -181,147 +193,159 @@ class CourierSharedModule(reactContext: ReactApplicationContext): ReactNativeMod
181
193
  }
182
194
 
183
195
  @ReactMethod
184
- fun openMessage(messageId: String, promise: Promise) = CoroutineScope(Dispatchers.Main).launch {
185
- try {
186
- Courier.shared.openMessage(messageId)
187
- promise.resolve(null)
188
- } catch (e: Exception) {
189
- promise.apiError(e)
196
+ fun openMessage(messageId: String, promise: Promise) {
197
+ CoroutineScope(Dispatchers.Main).launch {
198
+ try {
199
+ Courier.shared.openMessage(messageId)
200
+ promise.resolve(null)
201
+ } catch (e: Exception) {
202
+ promise.apiError(e)
203
+ }
190
204
  }
191
205
  }
192
206
 
193
207
  @ReactMethod
194
- fun archiveMessage(messageId: String, promise: Promise) = CoroutineScope(Dispatchers.Main).launch {
195
- try {
196
- Courier.shared.archiveMessage(messageId)
197
- promise.resolve(null)
198
- } catch (e: Exception) {
199
- promise.apiError(e)
208
+ fun archiveMessage(messageId: String, promise: Promise) {
209
+ CoroutineScope(Dispatchers.Main).launch {
210
+ try {
211
+ Courier.shared.archiveMessage(messageId)
212
+ promise.resolve(null)
213
+ } catch (e: Exception) {
214
+ promise.apiError(e)
215
+ }
200
216
  }
201
217
  }
202
218
 
203
219
  @ReactMethod
204
- fun clickMessage(messageId: String, promise: Promise) = CoroutineScope(Dispatchers.Main).launch {
205
- try {
206
- Courier.shared.clickMessage(messageId)
207
- promise.resolve(null)
208
- } catch (e: Exception) {
209
- promise.apiError(e)
220
+ fun clickMessage(messageId: String, promise: Promise) {
221
+ CoroutineScope(Dispatchers.Main).launch {
222
+ try {
223
+ Courier.shared.clickMessage(messageId)
224
+ promise.resolve(null)
225
+ } catch (e: Exception) {
226
+ promise.apiError(e)
227
+ }
210
228
  }
211
229
  }
212
230
 
213
231
  @ReactMethod
214
- fun readMessage(messageId: String, promise: Promise) = CoroutineScope(Dispatchers.Main).launch {
215
- try {
216
- Courier.shared.readMessage(messageId)
217
- promise.resolve(null)
218
- } catch (e: Exception) {
219
- promise.apiError(e)
232
+ fun readMessage(messageId: String, promise: Promise) {
233
+ CoroutineScope(Dispatchers.Main).launch {
234
+ try {
235
+ Courier.shared.readMessage(messageId)
236
+ promise.resolve(null)
237
+ } catch (e: Exception) {
238
+ promise.apiError(e)
239
+ }
220
240
  }
221
241
  }
222
242
 
223
243
  @ReactMethod
224
- fun unreadMessage(messageId: String, promise: Promise) = CoroutineScope(Dispatchers.Main).launch {
225
- try {
226
- Courier.shared.unreadMessage(messageId)
227
- promise.resolve(null)
228
- } catch (e: Exception) {
229
- promise.apiError(e)
244
+ fun unreadMessage(messageId: String, promise: Promise) {
245
+ CoroutineScope(Dispatchers.Main).launch {
246
+ try {
247
+ Courier.shared.unreadMessage(messageId)
248
+ promise.resolve(null)
249
+ } catch (e: Exception) {
250
+ promise.apiError(e)
251
+ }
230
252
  }
231
253
  }
232
254
 
233
255
  @ReactMethod
234
- fun readAllInboxMessages(promise: Promise) = CoroutineScope(Dispatchers.Main).launch {
235
- try {
236
- Courier.shared.readAllInboxMessages()
237
- promise.resolve(null)
238
- } catch (e: Exception) {
239
- promise.apiError(e)
256
+ fun readAllInboxMessages(promise: Promise) {
257
+ CoroutineScope(Dispatchers.Main).launch {
258
+ try {
259
+ Courier.shared.readAllInboxMessages()
260
+ promise.resolve(null)
261
+ } catch (e: Exception) {
262
+ promise.apiError(e)
263
+ }
240
264
  }
241
265
  }
242
266
 
243
267
  @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) {
245
-
246
- val listener = Courier.shared.addInboxListener(
247
- onLoading = { isRefresh ->
248
- reactApplicationContext.sendEvent(
249
- eventName = loadingId,
250
- value = isRefresh
251
- )
252
- },
253
- onError = { e ->
254
- reactApplicationContext.sendEvent(
255
- eventName = errorId,
256
- value = e.message ?: "Courier Inbox Error"
257
- )
258
- },
259
- onUnreadCountChanged = { unreadCount ->
260
- reactApplicationContext.sendEvent(
261
- eventName = unreadCountId,
262
- value = unreadCount
263
- )
264
- },
265
- onFeedChanged = { messageSet ->
266
- reactApplicationContext.sendEvent(
267
- eventName = feedId,
268
- value = messageSet.toJson()
269
- )
270
- },
271
- onArchiveChanged = { messageSet ->
272
- reactApplicationContext.sendEvent(
273
- eventName = archiveId,
274
- value = messageSet.toJson()
275
- )
276
- },
277
- onPageAdded = { feed, messageSet ->
278
- val json = Arguments.createMap()
279
- json.putString("feed", if (feed == InboxMessageFeed.FEED) "feed" else "archived")
280
- json.putArray("messages", messageSet.messages.map { it.toJson() }.toWritableArray())
281
- json.putInt("totalMessageCount", messageSet.totalCount)
282
- json.putBoolean("canPaginate", messageSet.canPaginate)
283
- reactApplicationContext.sendEvent(
284
- eventName = pageAddedId,
285
- value = json
286
- )
287
- },
288
- onMessageAdded = { feed, index, message ->
289
- val json = Arguments.createMap()
290
- json.putString("feed", if (feed == InboxMessageFeed.FEED) "feed" else "archived")
291
- json.putInt("index", index)
292
- json.putString("message", message.toJson())
293
- reactApplicationContext.sendEvent(
294
- eventName = messageAddedId,
295
- value = json
296
- )
297
- },
298
- onMessageChanged = { feed, index, message ->
299
- val json = Arguments.createMap()
300
- json.putString("feed", if (feed == InboxMessageFeed.FEED) "feed" else "archived")
301
- json.putInt("index", index)
302
- json.putString("message", message.toJson())
303
- reactApplicationContext.sendEvent(
304
- eventName = messageChangedId,
305
- value = json
306
- )
307
- },
308
- onMessageRemoved = { feed, index, message ->
309
- val json = Arguments.createMap()
310
- json.putString("feed", if (feed == InboxMessageFeed.FEED) "feed" else "archived")
311
- json.putInt("index", index)
312
- json.putString("message", message.toJson())
313
- reactApplicationContext.sendEvent(
314
- eventName = messageRemovedId,
315
- value = json
316
- )
317
- },
318
- )
319
-
320
- // Add listener
321
- inboxListeners[listenerId] = listener
322
-
323
- promise.resolve(listenerId)
268
+ fun addInboxListener(
269
+ listenerId: String,
270
+ loadingId: String,
271
+ errorId: String,
272
+ unreadCountId: String,
273
+ totalCountId: String,
274
+ messagesChangedId: String,
275
+ pageAddedId: String,
276
+ messageEventId: String,
277
+ promise: Promise
278
+ ) {
279
+ CoroutineScope(Dispatchers.Main).launch {
280
+ val listener = Courier.shared.addInboxListener(
281
+ onLoading = { isRefresh ->
282
+ reactApplicationContext.sendEvent(
283
+ eventName = loadingId,
284
+ value = isRefresh
285
+ )
286
+ },
287
+ onError = { e ->
288
+ reactApplicationContext.sendEvent(
289
+ eventName = errorId,
290
+ value = e.message ?: "Courier Inbox Error"
291
+ )
292
+ },
293
+ onUnreadCountChanged = { unreadCount ->
294
+ reactApplicationContext.sendEvent(
295
+ eventName = unreadCountId,
296
+ value = unreadCount
297
+ )
298
+ },
299
+ onTotalCountChanged = { totalCount, feed ->
300
+ val json = Arguments.createMap().apply {
301
+ putString("feed", if (feed == InboxMessageFeed.FEED) "feed" else "archive")
302
+ putInt("totalCount", totalCount)
303
+ }
304
+ reactApplicationContext.sendEvent(
305
+ eventName = totalCountId,
306
+ value = json
307
+ )
308
+ },
309
+ onMessagesChanged = { messages, canPaginate, feed ->
310
+ val json = Arguments.createMap().apply {
311
+ putString("feed", if (feed == InboxMessageFeed.FEED) "feed" else "archive")
312
+ putArray("messages", messages.map { it.toJson() }.toWritableArray())
313
+ putBoolean("canPaginate", canPaginate)
314
+ }
315
+ reactApplicationContext.sendEvent(
316
+ eventName = messagesChangedId,
317
+ value = json
318
+ )
319
+ },
320
+ onPageAdded = { messages, canPaginate, isFirstPage, feed ->
321
+ val json = Arguments.createMap().apply {
322
+ putString("feed", if (feed == InboxMessageFeed.FEED) "feed" else "archive")
323
+ putArray("messages", messages.map { it.toJson() }.toWritableArray())
324
+ putBoolean("canPaginate", canPaginate)
325
+ putBoolean("isFirstPage", isFirstPage)
326
+ }
327
+ reactApplicationContext.sendEvent(
328
+ eventName = pageAddedId,
329
+ value = json
330
+ )
331
+ },
332
+ onMessageEvent = { message, index, feed, event ->
333
+ val json = Arguments.createMap().apply {
334
+ putString("feed", if (feed == InboxMessageFeed.FEED) "feed" else "archive")
335
+ putInt("index", index)
336
+ putString("event", event.value)
337
+ putString("message", message.toJson())
338
+ }
339
+ reactApplicationContext.sendEvent(
340
+ eventName = messageEventId,
341
+ value = json
342
+ )
343
+ }
344
+ )
324
345
 
346
+ inboxListeners[listenerId] = listener
347
+ promise.resolve(listenerId)
348
+ }
325
349
  }
326
350
 
327
351
  private fun InboxMessageSet.toJson(): WritableMap? {
@@ -348,19 +372,24 @@ class CourierSharedModule(reactContext: ReactApplicationContext): ReactNativeMod
348
372
  }
349
373
 
350
374
  @ReactMethod
351
- fun refreshInbox(promise: Promise) = CoroutineScope(Dispatchers.Main).launch {
352
- Courier.shared.refreshInbox()
353
- promise.resolve(null)
375
+ fun refreshInbox(promise: Promise) {
376
+ CoroutineScope(Dispatchers.Main).launch {
377
+ Courier.shared.refreshInbox()
378
+ promise.resolve(null)
379
+ }
354
380
  }
355
381
 
356
382
  @ReactMethod
357
- fun fetchNextPageOfMessages(promise: Promise, inboxMessageFeed: String) = CoroutineScope(Dispatchers.Main).launch {
358
- try {
359
- val messageSet = Courier.shared.fetchNextInboxPage(if (inboxMessageFeed == "archived") InboxMessageFeed.ARCHIVE else InboxMessageFeed.FEED)
360
- promise.resolve(messageSet?.toJson())
361
- } catch (e: Exception) {
362
- promise.apiError(e)
383
+ fun fetchNextPageOfMessages(promise: Promise, inboxMessageFeed: String) {
384
+ CoroutineScope(Dispatchers.Main).launch {
385
+ try {
386
+ val messageSet = Courier.shared.fetchNextInboxPage(
387
+ if (inboxMessageFeed == "archived") InboxMessageFeed.ARCHIVE else InboxMessageFeed.FEED
388
+ )
389
+ promise.resolve(messageSet?.toJson())
390
+ } catch (e: Exception) {
391
+ promise.apiError(e)
392
+ }
363
393
  }
364
394
  }
365
-
366
395
  }
@@ -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.4.3")
18
+ val COURIER_AGENT = CourierAgent.ReactNativeAndroid(version = "5.5.1")
19
19
  }
20
20
 
21
21
  internal fun ReactContext.sendEvent(eventName: String, value: Any?) {
@@ -17,7 +17,7 @@ Pod::Spec.new do |s|
17
17
  s.source_files = "ios/**/*.{h,m,mm,swift}"
18
18
 
19
19
  # Courier Core Dependency
20
- s.dependency "Courier_iOS", "5.6.1"
20
+ s.dependency "Courier_iOS", "5.7.4"
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.
@@ -10,10 +10,14 @@
10
10
  #pragma GCC diagnostic ignored "-Wprotocol"
11
11
  #pragma clang diagnostic ignored "-Wprotocol"
12
12
 
13
- @implementation CourierReactNativeDelegate
13
+ @interface CourierReactNativeDelegate ()
14
+
15
+ @property (nonatomic, copy) NSString *iosForegroundNotificationPresentationOptions;
16
+ @property (nonatomic, assign) UNNotificationPresentationOptions notificationPresentationOptions;
14
17
 
15
- NSString *iosForegroundNotificationPresentationOptions = @"iosForegroundNotificationPresentationOptions";
16
- NSUInteger notificationPresentationOptions = UNNotificationPresentationOptionNone;
18
+ @end
19
+
20
+ @implementation CourierReactNativeDelegate
17
21
 
18
22
  - (id) init {
19
23
 
@@ -22,7 +26,7 @@ NSUInteger notificationPresentationOptions = UNNotificationPresentationOptionNon
22
26
  if (self) {
23
27
 
24
28
  // Set the user agent
25
- Courier.agent = [CourierAgent reactNativeIOS:@"5.4.3"];
29
+ Courier.agent = [CourierAgent reactNativeIOS:@"5.5.1"];
26
30
 
27
31
  // Register for remote notifications
28
32
  UIApplication *app = [UIApplication sharedApplication];
@@ -35,7 +39,7 @@ NSUInteger notificationPresentationOptions = UNNotificationPresentationOptionNon
35
39
  [[NSNotificationCenter defaultCenter]
36
40
  addObserver:self
37
41
  selector:@selector(notificationPresentationOptionsUpdate:)
38
- name:iosForegroundNotificationPresentationOptions
42
+ name:_iosForegroundNotificationPresentationOptions
39
43
  object:nil
40
44
  ];
41
45
 
@@ -47,10 +51,10 @@ NSUInteger notificationPresentationOptions = UNNotificationPresentationOptionNon
47
51
 
48
52
  - (void) notificationPresentationOptionsUpdate:(NSNotification *) notification
49
53
  {
50
- if ([[notification name] isEqualToString:iosForegroundNotificationPresentationOptions])
54
+ if ([[notification name] isEqualToString:_iosForegroundNotificationPresentationOptions])
51
55
  {
52
56
  NSDictionary *userInfo = notification.userInfo;
53
- notificationPresentationOptions = ((NSNumber *) [userInfo objectForKey:@"options"]).unsignedIntegerValue;
57
+ _notificationPresentationOptions = ((NSNumber *) [userInfo objectForKey:@"options"]).unsignedIntegerValue;
54
58
  }
55
59
  }
56
60
 
@@ -71,7 +75,7 @@ NSUInteger notificationPresentationOptions = UNNotificationPresentationOptionNon
71
75
  NSDictionary *pushNotification = [Courier formatPushNotificationWithContent:content];
72
76
  [[NSNotificationCenter defaultCenter] postNotificationName:@"pushNotificationDelivered" object:nil userInfo:pushNotification];
73
77
 
74
- completionHandler(notificationPresentationOptions);
78
+ completionHandler(self->_notificationPresentationOptions);
75
79
 
76
80
  });
77
81
 
@@ -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.4.3")
17
+ Courier.agent = CourierAgent.reactNativeIOS("5.5.1")
18
18
 
19
19
  }
20
20
 
@@ -139,12 +139,10 @@ RCT_EXTERN_METHOD(
139
139
  withLoadingId: (NSString*)loadingId
140
140
  withErrorId: (NSString*)errorId
141
141
  withUnreadCountId: (NSString*)unreadCountId
142
- withFeedId: (NSString*)feedId
143
- withArchiveId: (NSString*)archiveId
142
+ withTotalCountId: (NSString*)totalCountId
143
+ withMessagesChangedId: (NSString*)messagesChangedId
144
144
  withPageAddedId: (NSString*)pageAddedId
145
- withMessageChangedId: (NSString*)messageChangedId
146
- withMessageAddedId: (NSString*)messageAddedId
147
- withMessageRemovedId: (NSString*)messageRemovedId
145
+ withMessageEventId: (NSString*)messageEventId
148
146
  withResolver: (RCTPromiseResolveBlock)resolve
149
147
  withRejecter: (RCTPromiseRejectBlock)reject
150
148
  )