@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.
- package/android/build.gradle +2 -2
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/courierreactnative/CourierClientModule.kt +298 -303
- package/android/src/main/java/com/courierreactnative/CourierSharedModule.kt +194 -165
- package/android/src/main/java/com/courierreactnative/Utils.kt +1 -1
- package/courier-react-native.podspec +1 -1
- package/ios/CourierReactNativeDelegate.m +12 -8
- package/ios/CourierReactNativeEventEmitter.swift +1 -1
- package/ios/CourierReactNativeModule.m +3 -5
- package/ios/CourierSharedModule.swift +88 -112
- package/lib/commonjs/index.js +75 -93
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/models/CourierInboxListener.js +1 -0
- package/lib/commonjs/models/CourierInboxListener.js.map +1 -1
- package/lib/commonjs/models/InboxAction.js +22 -0
- package/lib/commonjs/models/InboxAction.js.map +1 -1
- package/lib/commonjs/models/InboxMessage.js +64 -0
- package/lib/commonjs/models/InboxMessage.js.map +1 -1
- package/lib/commonjs/models/InboxMessageEvent.js +2 -0
- package/lib/commonjs/models/InboxMessageEvent.js.map +1 -0
- package/lib/commonjs/views/CourierInboxView.js +6 -4
- package/lib/commonjs/views/CourierInboxView.js.map +1 -1
- package/lib/example/src/App.js +11 -0
- package/lib/example/src/Emitter.js +11 -0
- package/lib/example/src/Env.js +6 -0
- package/lib/example/src/Home.js +67 -0
- package/lib/example/src/Poke.js +75 -0
- package/lib/example/src/Tabs.js +36 -0
- package/lib/example/src/Utils.js +71 -0
- package/lib/example/src/pages/Auth.js +224 -0
- package/lib/example/src/pages/Inbox.js +38 -0
- package/lib/example/src/pages/Preferences.js +13 -0
- package/lib/example/src/pages/PreferencesStack.js +11 -0
- package/lib/example/src/pages/Push.js +93 -0
- package/lib/example/src/pages/Styles.js +26 -0
- package/lib/example/src/pages/Tests.js +1068 -0
- package/lib/example/src/pages/inbox/InboxCustom.js +141 -0
- package/lib/example/src/pages/inbox/InboxDefault.js +22 -0
- package/lib/example/src/pages/inbox/InboxStyled.js +220 -0
- package/lib/example/src/pages/preferences/PreferencesCustom.js +91 -0
- package/lib/example/src/pages/preferences/PreferencesDefault.js +17 -0
- package/lib/example/src/pages/preferences/PreferencesDetail.js +127 -0
- package/lib/example/src/pages/preferences/PreferencesStyled.js +110 -0
- package/lib/module/index.js +67 -90
- package/lib/module/index.js.map +1 -1
- package/lib/module/models/CourierInboxListener.js +1 -0
- package/lib/module/models/CourierInboxListener.js.map +1 -1
- package/lib/module/models/InboxAction.js +16 -1
- package/lib/module/models/InboxAction.js.map +1 -1
- package/lib/module/models/InboxMessage.js +61 -1
- package/lib/module/models/InboxMessage.js.map +1 -1
- package/lib/module/models/InboxMessageEvent.js +2 -0
- package/lib/module/models/InboxMessageEvent.js.map +1 -0
- package/lib/module/views/CourierInboxView.js +6 -4
- package/lib/module/views/CourierInboxView.js.map +1 -1
- package/lib/package.json +171 -0
- package/lib/src/Broadcaster.js +24 -0
- package/lib/src/Modules.js +26 -0
- package/lib/src/client/BrandClient.js +17 -0
- package/lib/src/client/ClientModule.js +14 -0
- package/lib/src/client/CourierClient.js +31 -0
- package/lib/src/client/InboxClient.js +99 -0
- package/lib/src/client/PreferenceClient.js +63 -0
- package/lib/src/client/TokenClient.js +27 -0
- package/lib/src/client/TrackingClient.js +17 -0
- package/lib/src/index.js +567 -0
- package/lib/src/models/Android_CourierSheet.js +1 -0
- package/lib/src/models/CourierAuthenticationListener.js +14 -0
- package/lib/src/models/CourierBrand.js +1 -0
- package/lib/src/models/CourierButton.js +1 -0
- package/lib/src/models/CourierDevice.js +1 -0
- package/lib/src/models/CourierFont.js +1 -0
- package/lib/src/models/CourierInboxListener.js +20 -0
- package/lib/src/models/CourierInboxMessages.js +1 -0
- package/lib/src/models/CourierInboxTheme.js +1 -0
- package/lib/src/models/CourierInfoViewStyle.js +1 -0
- package/lib/src/models/CourierPaging.js +1 -0
- package/lib/src/models/CourierPreferencesTheme.js +1 -0
- package/lib/src/models/CourierPushListener.js +14 -0
- package/lib/src/models/CourierPushProvider.js +8 -0
- package/lib/src/models/CourierTrackingEvent.js +8 -0
- package/lib/src/models/CourierUserPreferences.js +51 -0
- package/lib/src/models/InboxAction.js +1 -0
- package/lib/src/models/InboxMessage.js +1 -0
- package/lib/src/models/InboxMessageFeed.js +1 -0
- package/lib/src/models/InboxMessageSet.js +1 -0
- package/lib/src/models/iOS_CourierCell.js +1 -0
- package/lib/src/models/iOS_CourierSheet.js +1 -0
- package/lib/src/utils.js +27 -0
- package/lib/src/views/CourierInboxView.js +75 -0
- package/lib/src/views/CourierPreferencesView.js +33 -0
- package/lib/typescript/src/index.d.ts +16 -20
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/models/CourierInboxListener.d.ts +4 -7
- package/lib/typescript/src/models/CourierInboxListener.d.ts.map +1 -1
- package/lib/typescript/src/models/InboxAction.d.ts +8 -4
- package/lib/typescript/src/models/InboxAction.d.ts.map +1 -1
- package/lib/typescript/src/models/InboxMessage.d.ts +28 -14
- package/lib/typescript/src/models/InboxMessage.d.ts.map +1 -1
- package/lib/typescript/src/models/InboxMessageEvent.d.ts +2 -0
- package/lib/typescript/src/models/InboxMessageEvent.d.ts.map +1 -0
- package/lib/typescript/src/models/InboxMessageFeed.d.ts +1 -1
- package/lib/typescript/src/models/InboxMessageFeed.d.ts.map +1 -1
- package/package.json +3 -2
- package/src/index.tsx +61 -99
- package/src/models/CourierInboxListener.tsx +10 -13
- package/src/models/InboxAction.tsx +28 -4
- package/src/models/InboxMessage.tsx +102 -14
- package/src/models/InboxMessageEvent.tsx +1 -0
- package/src/models/InboxMessageFeed.tsx +1 -1
- package/src/views/CourierInboxView.tsx +4 -4
- package/ios/CourierReactNative.xcodeproj/project.xcworkspace/contents.xcworkspacedata +0 -7
- package/ios/CourierReactNative.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +0 -8
- package/ios/CourierReactNative.xcodeproj/project.xcworkspace/xcuserdata/mike.xcuserdatad/UserInterfaceState.xcuserstate +0 -0
- 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
|
-
|
|
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(
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
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)
|
|
98
|
-
|
|
99
|
-
|
|
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)
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
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)
|
|
156
|
-
|
|
157
|
-
|
|
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)
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
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)
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
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)
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
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)
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
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)
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
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)
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
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)
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
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(
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
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)
|
|
352
|
-
|
|
353
|
-
|
|
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)
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
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.
|
|
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.
|
|
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
|
-
@
|
|
13
|
+
@interface CourierReactNativeDelegate ()
|
|
14
|
+
|
|
15
|
+
@property (nonatomic, copy) NSString *iosForegroundNotificationPresentationOptions;
|
|
16
|
+
@property (nonatomic, assign) UNNotificationPresentationOptions notificationPresentationOptions;
|
|
14
17
|
|
|
15
|
-
|
|
16
|
-
|
|
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.
|
|
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:
|
|
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:
|
|
54
|
+
if ([[notification name] isEqualToString:_iosForegroundNotificationPresentationOptions])
|
|
51
55
|
{
|
|
52
56
|
NSDictionary *userInfo = notification.userInfo;
|
|
53
|
-
|
|
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(
|
|
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.
|
|
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
|
-
|
|
143
|
-
|
|
142
|
+
withTotalCountId: (NSString*)totalCountId
|
|
143
|
+
withMessagesChangedId: (NSString*)messagesChangedId
|
|
144
144
|
withPageAddedId: (NSString*)pageAddedId
|
|
145
|
-
|
|
146
|
-
withMessageAddedId: (NSString*)messageAddedId
|
|
147
|
-
withMessageRemovedId: (NSString*)messageRemovedId
|
|
145
|
+
withMessageEventId: (NSString*)messageEventId
|
|
148
146
|
withResolver: (RCTPromiseResolveBlock)resolve
|
|
149
147
|
withRejecter: (RCTPromiseRejectBlock)reject
|
|
150
148
|
)
|