@ua/react-native-airship 20.1.0 → 21.0.0
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/gradle.properties +4 -4
- package/android/src/main/java/com/urbanairship/reactnative/AirshipModule.kt +132 -166
- package/android/src/main/java/com/urbanairship/reactnative/ReactAutopilot.kt +26 -3
- package/android/src/main/java/com/urbanairship/reactnative/ReactMessageView.kt +71 -55
- package/android/src/main/java/com/urbanairship/reactnative/ReactNotificationProvider.kt +0 -5
- package/android/src/oldarch/java/com/urbanairship/reactnative/AirshipSpec.kt +14 -2
- package/ios/AirshipReactNative.swift +106 -25
- package/ios/MessageWebViewWrapper.swift +6 -6
- package/ios/ProxyDataMigrator.swift +1 -0
- package/ios/RTNAirship.mm +40 -2
- package/lib/commonjs/AirshipFeatureFlagManager.js +53 -14
- package/lib/commonjs/AirshipFeatureFlagManager.js.map +1 -1
- package/lib/commonjs/NativeRTNAirship.js.map +1 -1
- package/lib/module/AirshipFeatureFlagManager.js +51 -13
- package/lib/module/AirshipFeatureFlagManager.js.map +1 -1
- package/lib/module/NativeRTNAirship.js.map +1 -1
- package/lib/typescript/AirshipFeatureFlagManager.d.ts +39 -12
- package/lib/typescript/AirshipFeatureFlagManager.d.ts.map +1 -1
- package/lib/typescript/NativeRTNAirship.d.ts +4 -1
- package/lib/typescript/NativeRTNAirship.d.ts.map +1 -1
- package/package.json +1 -1
- package/react-native-airship.podspec +2 -3
- package/src/AirshipFeatureFlagManager.ts +47 -7
- package/src/NativeRTNAirship.ts +4 -1
|
@@ -19,6 +19,7 @@ import com.urbanairship.android.framework.proxy.proxies.SuspendingPredicate
|
|
|
19
19
|
import com.urbanairship.json.JsonMap
|
|
20
20
|
import com.urbanairship.json.JsonSerializable
|
|
21
21
|
import com.urbanairship.json.JsonValue
|
|
22
|
+
import kotlin.time.Duration.Companion.milliseconds
|
|
22
23
|
import kotlinx.coroutines.*
|
|
23
24
|
import kotlinx.coroutines.flow.filter
|
|
24
25
|
import java.util.UUID
|
|
@@ -64,10 +65,10 @@ class AirshipModule internal constructor(val context: ReactApplicationContext) :
|
|
|
64
65
|
// Background events will create a headless JS task in ReactAutopilot since
|
|
65
66
|
// initialized wont be called until we have a JS task.
|
|
66
67
|
EventEmitter.shared().pendingEventListener
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
.filter { it.type.isForeground() }
|
|
69
|
+
.collect {
|
|
70
|
+
notifyPending()
|
|
71
|
+
}
|
|
71
72
|
}
|
|
72
73
|
|
|
73
74
|
context.addLifecycleEventListener(object : LifecycleEventListener {
|
|
@@ -93,14 +94,14 @@ class AirshipModule internal constructor(val context: ReactApplicationContext) :
|
|
|
93
94
|
|
|
94
95
|
@ReactMethod
|
|
95
96
|
override fun takeOff(config: ReadableMap?, promise: Promise) {
|
|
96
|
-
promise.
|
|
97
|
+
promise.resolve(scope) {
|
|
97
98
|
proxy.takeOff(Utils.convertMap(requireNotNull(config)).toJsonValue())
|
|
98
99
|
}
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
@ReactMethod
|
|
102
103
|
override fun isFlying(promise: Promise) {
|
|
103
|
-
promise.
|
|
104
|
+
promise.resolve(scope) {
|
|
104
105
|
this.proxy.isFlying()
|
|
105
106
|
}
|
|
106
107
|
}
|
|
@@ -128,7 +129,7 @@ class AirshipModule internal constructor(val context: ReactApplicationContext) :
|
|
|
128
129
|
@SuppressLint("RestrictedApi")
|
|
129
130
|
@ReactMethod
|
|
130
131
|
override fun takePendingEvents(eventName: String?, isHeadlessJS: Boolean, promise: Promise) {
|
|
131
|
-
promise.
|
|
132
|
+
promise.resolve(scope) {
|
|
132
133
|
val eventTypes = Utils.parseEventTypes(requireNotNull(eventName))
|
|
133
134
|
.filter {
|
|
134
135
|
if (isHeadlessJS) {
|
|
@@ -156,93 +157,91 @@ class AirshipModule internal constructor(val context: ReactApplicationContext) :
|
|
|
156
157
|
|
|
157
158
|
@ReactMethod
|
|
158
159
|
override fun channelEnableChannelCreation(promise: Promise) {
|
|
159
|
-
promise.
|
|
160
|
+
promise.resolve(scope) {
|
|
160
161
|
proxy.channel.enableChannelCreation()
|
|
161
162
|
}
|
|
162
163
|
}
|
|
163
164
|
|
|
164
165
|
@ReactMethod
|
|
165
166
|
override fun channelAddTag(tag: String?, promise: Promise) {
|
|
166
|
-
promise.
|
|
167
|
+
promise.resolve(scope) {
|
|
167
168
|
proxy.channel.addTag(requireNotNull(tag))
|
|
168
169
|
}
|
|
169
170
|
}
|
|
170
171
|
|
|
171
172
|
@ReactMethod
|
|
172
173
|
override fun channelRemoveTag(tag: String?, promise: Promise) {
|
|
173
|
-
promise.
|
|
174
|
+
promise.resolve(scope) {
|
|
174
175
|
proxy.channel.removeTag(requireNotNull(tag))
|
|
175
176
|
}
|
|
176
177
|
}
|
|
177
178
|
|
|
178
179
|
@ReactMethod
|
|
179
180
|
override fun channelEditTags(operations: ReadableArray?, promise: Promise) {
|
|
180
|
-
promise.
|
|
181
|
+
promise.resolve(scope) {
|
|
181
182
|
proxy.channel.editTags(Utils.convertArray(operations).toJsonValue())
|
|
182
183
|
}
|
|
183
184
|
}
|
|
184
185
|
|
|
185
186
|
@ReactMethod
|
|
186
187
|
override fun channelGetTags(promise: Promise) {
|
|
187
|
-
promise.
|
|
188
|
-
|
|
188
|
+
promise.resolve(scope) {
|
|
189
|
+
proxy.channel.getTags()
|
|
189
190
|
}
|
|
190
191
|
}
|
|
191
192
|
|
|
192
193
|
@ReactMethod
|
|
193
194
|
override fun channelGetChannelId(promise: Promise) {
|
|
194
|
-
promise.
|
|
195
|
+
promise.resolve(scope) {
|
|
195
196
|
proxy.channel.getChannelId()
|
|
196
197
|
}
|
|
197
198
|
}
|
|
198
199
|
|
|
199
200
|
@ReactMethod
|
|
200
201
|
override fun channelGetSubscriptionLists(promise: Promise) {
|
|
201
|
-
promise.
|
|
202
|
-
proxy.channel.getSubscriptionLists()
|
|
203
|
-
callback(JsonValue.wrapOpt(it), null)
|
|
204
|
-
}
|
|
202
|
+
promise.resolve(scope) {
|
|
203
|
+
proxy.channel.getSubscriptionLists()
|
|
205
204
|
}
|
|
206
205
|
}
|
|
207
206
|
|
|
208
207
|
@ReactMethod
|
|
209
208
|
override fun channelEditTagGroups(operations: ReadableArray?, promise: Promise) {
|
|
210
|
-
promise.
|
|
209
|
+
promise.resolve(scope) {
|
|
211
210
|
proxy.channel.editTagGroups(Utils.convertArray(operations).toJsonValue())
|
|
212
211
|
}
|
|
213
212
|
}
|
|
214
213
|
|
|
215
214
|
@ReactMethod
|
|
216
215
|
override fun channelEditAttributes(operations: ReadableArray?, promise: Promise) {
|
|
217
|
-
promise.
|
|
216
|
+
promise.resolve(scope) {
|
|
218
217
|
proxy.channel.editAttributes(Utils.convertArray(operations).toJsonValue())
|
|
219
218
|
}
|
|
220
219
|
}
|
|
221
220
|
|
|
222
221
|
@ReactMethod
|
|
223
222
|
override fun channelEditSubscriptionLists(operations: ReadableArray?, promise: Promise) {
|
|
224
|
-
promise.
|
|
223
|
+
promise.resolve(scope) {
|
|
225
224
|
proxy.channel.editSubscriptionLists(Utils.convertArray(operations).toJsonValue())
|
|
226
225
|
}
|
|
227
226
|
}
|
|
228
227
|
|
|
229
228
|
@ReactMethod
|
|
230
229
|
override fun pushSetUserNotificationsEnabled(enabled: Boolean, promise: Promise) {
|
|
231
|
-
promise.
|
|
230
|
+
promise.resolve(scope) {
|
|
232
231
|
proxy.push.setUserNotificationsEnabled(enabled)
|
|
233
232
|
}
|
|
234
233
|
}
|
|
235
234
|
|
|
236
235
|
@ReactMethod
|
|
237
236
|
override fun pushIsUserNotificationsEnabled(promise: Promise) {
|
|
238
|
-
promise.
|
|
237
|
+
promise.resolve(scope) {
|
|
239
238
|
proxy.push.isUserNotificationsEnabled()
|
|
240
239
|
}
|
|
241
240
|
}
|
|
242
241
|
|
|
243
242
|
@ReactMethod
|
|
244
243
|
override fun pushEnableUserNotifications(options: ReadableMap?, promise: Promise) {
|
|
245
|
-
promise.
|
|
244
|
+
promise.resolve(scope) {
|
|
246
245
|
val args = options?.let {
|
|
247
246
|
EnableUserNotificationsArgs.fromJson(Utils.convertMap(it).toJsonValue())
|
|
248
247
|
}
|
|
@@ -252,22 +251,22 @@ class AirshipModule internal constructor(val context: ReactApplicationContext) :
|
|
|
252
251
|
|
|
253
252
|
@ReactMethod
|
|
254
253
|
override fun pushGetNotificationStatus(promise: Promise) {
|
|
255
|
-
promise.
|
|
254
|
+
promise.resolve(scope) {
|
|
256
255
|
proxy.push.getNotificationStatus()
|
|
257
256
|
}
|
|
258
257
|
}
|
|
259
258
|
|
|
260
259
|
@ReactMethod
|
|
261
260
|
override fun pushGetRegistrationToken(promise: Promise) {
|
|
262
|
-
promise.
|
|
261
|
+
promise.resolve(scope) {
|
|
263
262
|
proxy.push.getRegistrationToken()
|
|
264
263
|
}
|
|
265
264
|
}
|
|
266
265
|
|
|
267
266
|
@ReactMethod
|
|
268
267
|
override fun pushGetActiveNotifications(promise: Promise) {
|
|
269
|
-
promise.
|
|
270
|
-
|
|
268
|
+
promise.resolve(scope) {
|
|
269
|
+
proxy.push.getActiveNotifications()
|
|
271
270
|
}
|
|
272
271
|
}
|
|
273
272
|
|
|
@@ -288,42 +287,42 @@ class AirshipModule internal constructor(val context: ReactApplicationContext) :
|
|
|
288
287
|
options: ReadableArray?,
|
|
289
288
|
promise: Promise
|
|
290
289
|
) {
|
|
291
|
-
promise.
|
|
290
|
+
promise.resolve(scope) {
|
|
292
291
|
throw IllegalStateException("Not supported on Android")
|
|
293
292
|
}
|
|
294
293
|
}
|
|
295
294
|
|
|
296
295
|
@ReactMethod
|
|
297
296
|
override fun pushIosSetNotificationOptions(options: ReadableArray?, promise: Promise) {
|
|
298
|
-
promise.
|
|
297
|
+
promise.resolve(scope) {
|
|
299
298
|
throw IllegalStateException("Not supported on Android")
|
|
300
299
|
}
|
|
301
300
|
}
|
|
302
301
|
|
|
303
302
|
@ReactMethod
|
|
304
303
|
override fun pushIosSetAutobadgeEnabled(enabled: Boolean, promise: Promise) {
|
|
305
|
-
promise.
|
|
304
|
+
promise.resolve(scope) {
|
|
306
305
|
throw IllegalStateException("Not supported on Android")
|
|
307
306
|
}
|
|
308
307
|
}
|
|
309
308
|
|
|
310
309
|
@ReactMethod
|
|
311
310
|
override fun pushIosIsAutobadgeEnabled(promise: Promise) {
|
|
312
|
-
promise.
|
|
311
|
+
promise.resolve(scope) {
|
|
313
312
|
throw IllegalStateException("Not supported on Android")
|
|
314
313
|
}
|
|
315
314
|
}
|
|
316
315
|
|
|
317
316
|
@ReactMethod
|
|
318
317
|
override fun pushIosSetBadgeNumber(badgeNumber: Double, promise: Promise) {
|
|
319
|
-
promise.
|
|
318
|
+
promise.resolve(scope) {
|
|
320
319
|
throw IllegalStateException("Not supported on Android")
|
|
321
320
|
}
|
|
322
321
|
}
|
|
323
322
|
|
|
324
323
|
@ReactMethod
|
|
325
324
|
override fun pushIosGetBadgeNumber(promise: Promise) {
|
|
326
|
-
promise.
|
|
325
|
+
promise.resolve(scope) {
|
|
327
326
|
throw IllegalStateException("Not supported on Android")
|
|
328
327
|
}
|
|
329
328
|
}
|
|
@@ -350,7 +349,7 @@ class AirshipModule internal constructor(val context: ReactApplicationContext) :
|
|
|
350
349
|
|
|
351
350
|
@ReactMethod
|
|
352
351
|
override fun pushAndroidIsNotificationChannelEnabled(channel: String?, promise: Promise) {
|
|
353
|
-
promise.
|
|
352
|
+
promise.resolve(scope) {
|
|
354
353
|
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
|
|
355
354
|
proxy.push.isNotificationChannelEnabled(requireNotNull(channel))
|
|
356
355
|
} else {
|
|
@@ -391,51 +390,49 @@ class AirshipModule internal constructor(val context: ReactApplicationContext) :
|
|
|
391
390
|
|
|
392
391
|
@ReactMethod
|
|
393
392
|
override fun contactIdentify(namedUser: String?, promise: Promise) {
|
|
394
|
-
promise.
|
|
393
|
+
promise.resolve(scope) {
|
|
395
394
|
proxy.contact.identify(namedUser)
|
|
396
395
|
}
|
|
397
396
|
}
|
|
398
397
|
|
|
399
398
|
@ReactMethod
|
|
400
399
|
override fun contactReset(promise: Promise) {
|
|
401
|
-
promise.
|
|
400
|
+
promise.resolve(scope) {
|
|
402
401
|
proxy.contact.reset()
|
|
403
402
|
}
|
|
404
403
|
}
|
|
405
404
|
|
|
406
405
|
@ReactMethod
|
|
407
406
|
override fun contactNotifyRemoteLogin(promise: Promise) {
|
|
408
|
-
promise.
|
|
407
|
+
promise.resolve(scope) {
|
|
409
408
|
proxy.contact.notifyRemoteLogin()
|
|
410
409
|
}
|
|
411
410
|
}
|
|
412
411
|
|
|
413
412
|
@ReactMethod
|
|
414
413
|
override fun contactGetNamedUserId(promise: Promise) {
|
|
415
|
-
promise.
|
|
414
|
+
promise.resolve(scope) {
|
|
416
415
|
proxy.contact.getNamedUserId()
|
|
417
416
|
}
|
|
418
417
|
}
|
|
419
418
|
|
|
420
419
|
@ReactMethod
|
|
421
420
|
override fun contactGetSubscriptionLists(promise: Promise) {
|
|
422
|
-
promise.
|
|
423
|
-
proxy.contact.getSubscriptionLists()
|
|
424
|
-
callback(JsonValue.wrapOpt(it), null)
|
|
425
|
-
}
|
|
421
|
+
promise.resolve(scope) {
|
|
422
|
+
proxy.contact.getSubscriptionLists()
|
|
426
423
|
}
|
|
427
424
|
}
|
|
428
425
|
|
|
429
426
|
@ReactMethod
|
|
430
427
|
override fun contactEditTagGroups(operations: ReadableArray?, promise: Promise) {
|
|
431
|
-
promise.
|
|
428
|
+
promise.resolve(scope) {
|
|
432
429
|
proxy.contact.editTagGroups(Utils.convertArray(operations).toJsonValue())
|
|
433
430
|
}
|
|
434
431
|
}
|
|
435
432
|
|
|
436
433
|
@ReactMethod
|
|
437
434
|
override fun contactEditAttributes(operations: ReadableArray?, promise: Promise) {
|
|
438
|
-
promise.
|
|
435
|
+
promise.resolve(scope) {
|
|
439
436
|
proxy.contact.editAttributes(Utils.convertArray(operations).toJsonValue())
|
|
440
437
|
}
|
|
441
438
|
}
|
|
@@ -445,14 +442,14 @@ class AirshipModule internal constructor(val context: ReactApplicationContext) :
|
|
|
445
442
|
operations: ReadableArray?,
|
|
446
443
|
promise: Promise
|
|
447
444
|
) {
|
|
448
|
-
promise.
|
|
445
|
+
promise.resolve(scope) {
|
|
449
446
|
proxy.contact.editSubscriptionLists(Utils.convertArray(operations).toJsonValue())
|
|
450
447
|
}
|
|
451
448
|
}
|
|
452
449
|
|
|
453
450
|
@ReactMethod
|
|
454
451
|
override fun analyticsTrackScreen(screen: String?, promise: Promise) {
|
|
455
|
-
promise.
|
|
452
|
+
promise.resolve(scope) {
|
|
456
453
|
proxy.analytics.trackScreen(screen)
|
|
457
454
|
}
|
|
458
455
|
}
|
|
@@ -463,14 +460,14 @@ class AirshipModule internal constructor(val context: ReactApplicationContext) :
|
|
|
463
460
|
identifier: String?,
|
|
464
461
|
promise: Promise
|
|
465
462
|
) {
|
|
466
|
-
promise.
|
|
463
|
+
promise.resolve(scope) {
|
|
467
464
|
proxy.analytics.associateIdentifier(requireNotNull(key), identifier)
|
|
468
465
|
}
|
|
469
466
|
}
|
|
470
467
|
|
|
471
468
|
@ReactMethod
|
|
472
469
|
override fun addCustomEvent(event: ReadableMap?, promise: Promise) {
|
|
473
|
-
promise.
|
|
470
|
+
promise.resolve(scope) {
|
|
474
471
|
proxy.analytics.addEvent(Utils.convertMap(event).toJsonValue())
|
|
475
472
|
}
|
|
476
473
|
}
|
|
@@ -479,92 +476,90 @@ class AirshipModule internal constructor(val context: ReactApplicationContext) :
|
|
|
479
476
|
override fun analyticsGetSessionId(
|
|
480
477
|
promise: Promise
|
|
481
478
|
) {
|
|
482
|
-
promise.
|
|
479
|
+
promise.resolve(scope) {
|
|
483
480
|
proxy.analytics.getSessionId()
|
|
484
481
|
}
|
|
485
482
|
}
|
|
486
483
|
|
|
487
484
|
@ReactMethod
|
|
488
485
|
override fun actionRun(action: ReadableMap, promise: Promise) {
|
|
489
|
-
promise.
|
|
490
|
-
proxy.actions.runAction(requireNotNull(action.getString("name")), Utils.convertDynamic(action.getDynamic("value")))
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
}
|
|
497
|
-
}
|
|
486
|
+
promise.resolve(scope) {
|
|
487
|
+
val result = proxy.actions.runAction(requireNotNull(action.getString("name")), Utils.convertDynamic(action.getDynamic("value")))
|
|
488
|
+
if (result.status == ActionResult.STATUS_COMPLETED) {
|
|
489
|
+
result.value
|
|
490
|
+
} else {
|
|
491
|
+
throw Exception("Action failed ${result.status}")
|
|
492
|
+
}
|
|
498
493
|
}
|
|
499
494
|
}
|
|
500
495
|
|
|
501
496
|
@ReactMethod
|
|
502
497
|
override fun privacyManagerSetEnabledFeatures(features: ReadableArray?, promise: Promise) {
|
|
503
|
-
promise.
|
|
498
|
+
promise.resolve(scope) {
|
|
504
499
|
proxy.privacyManager.setEnabledFeatures(
|
|
505
|
-
|
|
500
|
+
Utils.convertArray(requireNotNull(features))
|
|
506
501
|
)
|
|
507
502
|
}
|
|
508
503
|
}
|
|
509
504
|
|
|
510
505
|
@ReactMethod
|
|
511
506
|
override fun privacyManagerGetEnabledFeatures(promise: Promise) {
|
|
512
|
-
promise.
|
|
513
|
-
|
|
507
|
+
promise.resolve(scope) {
|
|
508
|
+
proxy.privacyManager.getFeatureNames()
|
|
514
509
|
}
|
|
515
510
|
}
|
|
516
511
|
|
|
517
512
|
@ReactMethod
|
|
518
513
|
override fun privacyManagerEnableFeature(features: ReadableArray?, promise: Promise) {
|
|
519
|
-
promise.
|
|
514
|
+
promise.resolve(scope) {
|
|
520
515
|
proxy.privacyManager.enableFeatures(
|
|
521
|
-
|
|
516
|
+
Utils.convertArray(requireNotNull(features))
|
|
522
517
|
)
|
|
523
518
|
}
|
|
524
519
|
}
|
|
525
520
|
|
|
526
521
|
@ReactMethod
|
|
527
522
|
override fun privacyManagerDisableFeature(features: ReadableArray?, promise: Promise) {
|
|
528
|
-
promise.
|
|
523
|
+
promise.resolve(scope) {
|
|
529
524
|
proxy.privacyManager.disableFeatures(
|
|
530
|
-
|
|
525
|
+
Utils.convertArray(requireNotNull(features))
|
|
531
526
|
)
|
|
532
527
|
}
|
|
533
528
|
}
|
|
534
529
|
|
|
535
530
|
@ReactMethod
|
|
536
531
|
override fun privacyManagerIsFeatureEnabled(features: ReadableArray?, promise: Promise) {
|
|
537
|
-
promise.
|
|
532
|
+
promise.resolve(scope) {
|
|
538
533
|
proxy.privacyManager.isFeatureEnabled(
|
|
539
|
-
|
|
534
|
+
Utils.convertArray(requireNotNull(features))
|
|
540
535
|
)
|
|
541
536
|
}
|
|
542
537
|
}
|
|
543
538
|
|
|
544
539
|
@ReactMethod
|
|
545
540
|
override fun inAppSetDisplayInterval(milliseconds: Double, promise: Promise) {
|
|
546
|
-
promise.
|
|
541
|
+
promise.resolve(scope) {
|
|
547
542
|
this.proxy.inApp.setDisplayInterval(milliseconds.toLong())
|
|
548
543
|
}
|
|
549
544
|
}
|
|
550
545
|
|
|
551
546
|
@ReactMethod
|
|
552
547
|
override fun inAppGetDisplayInterval(promise: Promise) {
|
|
553
|
-
promise.
|
|
548
|
+
promise.resolve(scope) {
|
|
554
549
|
this.proxy.inApp.getDisplayInterval()
|
|
555
550
|
}
|
|
556
551
|
}
|
|
557
552
|
|
|
558
553
|
@ReactMethod
|
|
559
554
|
override fun inAppSetPaused(paused: Boolean, promise: Promise) {
|
|
560
|
-
promise.
|
|
555
|
+
promise.resolve(scope) {
|
|
561
556
|
proxy.inApp.setPaused(paused)
|
|
562
557
|
}
|
|
563
558
|
}
|
|
564
559
|
|
|
565
560
|
@ReactMethod
|
|
566
561
|
override fun inAppIsPaused(promise: Promise) {
|
|
567
|
-
promise.
|
|
562
|
+
promise.resolve(scope) {
|
|
568
563
|
proxy.inApp.isPaused()
|
|
569
564
|
}
|
|
570
565
|
}
|
|
@@ -576,55 +571,51 @@ class AirshipModule internal constructor(val context: ReactApplicationContext) :
|
|
|
576
571
|
|
|
577
572
|
@ReactMethod
|
|
578
573
|
override fun messageCenterGetUnreadCount(promise: Promise) {
|
|
579
|
-
promise.
|
|
574
|
+
promise.resolve(scope) {
|
|
580
575
|
proxy.messageCenter.getUnreadMessagesCount()
|
|
581
576
|
}
|
|
582
577
|
}
|
|
583
578
|
|
|
584
579
|
@ReactMethod
|
|
585
580
|
override fun messageCenterDismiss(promise: Promise) {
|
|
586
|
-
promise.
|
|
581
|
+
promise.resolve(scope) {
|
|
587
582
|
proxy.messageCenter.dismiss()
|
|
588
583
|
}
|
|
589
584
|
}
|
|
590
585
|
|
|
591
586
|
@ReactMethod
|
|
592
587
|
override fun messageCenterDisplay(messageId: String?, promise: Promise) {
|
|
593
|
-
promise.
|
|
588
|
+
promise.resolve(scope) {
|
|
594
589
|
proxy.messageCenter.display(messageId)
|
|
595
590
|
}
|
|
596
591
|
}
|
|
597
592
|
|
|
598
593
|
@ReactMethod
|
|
599
594
|
override fun messageCenterGetMessages(promise: Promise) {
|
|
600
|
-
promise.
|
|
601
|
-
|
|
595
|
+
promise.resolve(scope) {
|
|
596
|
+
proxy.messageCenter.getMessages()
|
|
602
597
|
}
|
|
603
598
|
}
|
|
604
599
|
|
|
605
600
|
@ReactMethod
|
|
606
601
|
override fun messageCenterDeleteMessage(messageId: String?, promise: Promise) {
|
|
607
|
-
promise.
|
|
602
|
+
promise.resolve(scope) {
|
|
608
603
|
proxy.messageCenter.deleteMessage(requireNotNull(messageId))
|
|
609
604
|
}
|
|
610
605
|
}
|
|
611
606
|
|
|
612
607
|
@ReactMethod
|
|
613
608
|
override fun messageCenterMarkMessageRead(messageId: String?, promise: Promise) {
|
|
614
|
-
promise.
|
|
609
|
+
promise.resolve(scope) {
|
|
615
610
|
proxy.messageCenter.markMessageRead(requireNotNull(messageId))
|
|
616
611
|
}
|
|
617
612
|
}
|
|
618
613
|
|
|
619
614
|
@ReactMethod
|
|
620
615
|
override fun messageCenterRefresh(promise: Promise) {
|
|
621
|
-
promise.
|
|
622
|
-
proxy.messageCenter.refreshInbox()
|
|
623
|
-
|
|
624
|
-
callback(null, null)
|
|
625
|
-
} else {
|
|
626
|
-
callback(null, Exception("Failed to refresh"))
|
|
627
|
-
}
|
|
616
|
+
promise.resolve(scope) {
|
|
617
|
+
if (!proxy.messageCenter.refreshInbox()) {
|
|
618
|
+
throw Exception("Failed to refresh")
|
|
628
619
|
}
|
|
629
620
|
}
|
|
630
621
|
}
|
|
@@ -636,28 +627,28 @@ class AirshipModule internal constructor(val context: ReactApplicationContext) :
|
|
|
636
627
|
|
|
637
628
|
@ReactMethod
|
|
638
629
|
override fun messageCenterShowMessageCenter(messageId: String?, promise: Promise) {
|
|
639
|
-
promise.
|
|
630
|
+
promise.resolve(scope) {
|
|
640
631
|
proxy.messageCenter.showMessageCenter(messageId)
|
|
641
632
|
}
|
|
642
633
|
}
|
|
643
634
|
|
|
644
635
|
@ReactMethod
|
|
645
636
|
override fun messageCenterShowMessageView(messageId: String?, promise: Promise) {
|
|
646
|
-
promise.
|
|
637
|
+
promise.resolve(scope) {
|
|
647
638
|
proxy.messageCenter.showMessageView(requireNotNull(messageId))
|
|
648
639
|
}
|
|
649
640
|
}
|
|
650
641
|
|
|
651
642
|
@ReactMethod
|
|
652
643
|
override fun preferenceCenterDisplay(preferenceCenterId: String?, promise: Promise) {
|
|
653
|
-
promise.
|
|
644
|
+
promise.resolve(scope) {
|
|
654
645
|
proxy.preferenceCenter.displayPreferenceCenter(requireNotNull(preferenceCenterId))
|
|
655
646
|
}
|
|
656
647
|
}
|
|
657
648
|
|
|
658
649
|
@ReactMethod
|
|
659
650
|
override fun preferenceCenterGetConfig(preferenceCenterId: String?, promise: Promise) {
|
|
660
|
-
promise.
|
|
651
|
+
promise.resolve(scope) {
|
|
661
652
|
proxy.preferenceCenter.getPreferenceCenterConfig(requireNotNull(preferenceCenterId))
|
|
662
653
|
}
|
|
663
654
|
}
|
|
@@ -674,7 +665,7 @@ class AirshipModule internal constructor(val context: ReactApplicationContext) :
|
|
|
674
665
|
|
|
675
666
|
@ReactMethod
|
|
676
667
|
override fun localeSetLocaleOverride(localeIdentifier: String?, promise: Promise) {
|
|
677
|
-
promise.
|
|
668
|
+
promise.resolve(scope) {
|
|
678
669
|
if (localeIdentifier.isNullOrEmpty()) {
|
|
679
670
|
proxy.locale.clearLocale()
|
|
680
671
|
} else {
|
|
@@ -685,92 +676,109 @@ class AirshipModule internal constructor(val context: ReactApplicationContext) :
|
|
|
685
676
|
|
|
686
677
|
@ReactMethod
|
|
687
678
|
override fun localeGetLocale(promise: Promise) {
|
|
688
|
-
promise.
|
|
679
|
+
promise.resolve(scope) {
|
|
689
680
|
proxy.locale.getCurrentLocale()
|
|
690
681
|
}
|
|
691
682
|
}
|
|
692
683
|
|
|
693
684
|
@ReactMethod
|
|
694
685
|
override fun localeClearLocaleOverride(promise: Promise) {
|
|
695
|
-
promise.
|
|
686
|
+
promise.resolve(scope) {
|
|
696
687
|
proxy.locale.clearLocale()
|
|
697
688
|
}
|
|
698
689
|
}
|
|
699
690
|
|
|
700
691
|
@ReactMethod
|
|
701
|
-
override fun featureFlagManagerFlag(flagName: String
|
|
702
|
-
promise.
|
|
703
|
-
|
|
704
|
-
proxy.featureFlagManager.flag(flagName)
|
|
692
|
+
override fun featureFlagManagerFlag(flagName: String, useResultCache: Boolean, promise: Promise) {
|
|
693
|
+
promise.resolve(scope) {
|
|
694
|
+
proxy.featureFlagManager.flag(flagName, useResultCache)
|
|
705
695
|
}
|
|
706
696
|
}
|
|
707
697
|
|
|
708
698
|
@ReactMethod
|
|
709
|
-
override fun featureFlagManagerTrackInteraction(flag: ReadableMap
|
|
710
|
-
promise.
|
|
711
|
-
val parsedFlag = FeatureFlagProxy(Utils.convertMap(
|
|
699
|
+
override fun featureFlagManagerTrackInteraction(flag: ReadableMap, promise: Promise) {
|
|
700
|
+
promise.resolve(scope) {
|
|
701
|
+
val parsedFlag = FeatureFlagProxy(Utils.convertMap(flag).toJsonValue())
|
|
712
702
|
proxy.featureFlagManager.trackInteraction(parsedFlag)
|
|
713
703
|
}
|
|
714
704
|
}
|
|
715
705
|
|
|
706
|
+
@ReactMethod
|
|
707
|
+
override fun featureFlagManagerResultCacheGetFlag(flagName: String, promise: Promise) {
|
|
708
|
+
promise.resolve(scope) {
|
|
709
|
+
proxy.featureFlagManager.resultCache.flag(flagName)
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
|
|
713
|
+
@ReactMethod
|
|
714
|
+
override fun featureFlagManagerResultCacheSetFlag(flag: ReadableMap, ttl: Double, promise: Promise) {
|
|
715
|
+
promise.resolve(scope) {
|
|
716
|
+
val parsedFlag = FeatureFlagProxy(Utils.convertMap(flag).toJsonValue())
|
|
717
|
+
proxy.featureFlagManager.resultCache.cache(parsedFlag, ttl.milliseconds)
|
|
718
|
+
}
|
|
719
|
+
}
|
|
720
|
+
|
|
721
|
+
@ReactMethod
|
|
722
|
+
override fun featureFlagManagerResultCacheRemoveFlag(flagName: String, promise: Promise) {
|
|
723
|
+
promise.resolve(scope) {
|
|
724
|
+
proxy.featureFlagManager.resultCache.removeCachedFlag(flagName)
|
|
725
|
+
}
|
|
726
|
+
}
|
|
727
|
+
|
|
716
728
|
@ReactMethod
|
|
717
729
|
override fun liveActivityListAll(promise: Promise) {
|
|
718
|
-
promise.
|
|
730
|
+
promise.resolve(scope) {
|
|
719
731
|
throw IllegalStateException("Not supported on Android")
|
|
720
732
|
}
|
|
721
733
|
}
|
|
722
734
|
|
|
723
735
|
@ReactMethod
|
|
724
736
|
override fun liveActivityList(request: ReadableMap?, promise: Promise) {
|
|
725
|
-
promise.
|
|
737
|
+
promise.resolve(scope) {
|
|
726
738
|
throw IllegalStateException("Not supported on Android")
|
|
727
739
|
}
|
|
728
740
|
}
|
|
729
741
|
|
|
730
742
|
@ReactMethod
|
|
731
743
|
override fun liveActivityStart(request: ReadableMap?, promise: Promise) {
|
|
732
|
-
promise.
|
|
744
|
+
promise.resolve(scope) {
|
|
733
745
|
throw IllegalStateException("Not supported on Android")
|
|
734
746
|
}
|
|
735
747
|
}
|
|
736
748
|
|
|
737
749
|
@ReactMethod
|
|
738
750
|
override fun liveActivityUpdate(request: ReadableMap?, promise: Promise) {
|
|
739
|
-
promise.
|
|
751
|
+
promise.resolve(scope) {
|
|
740
752
|
throw IllegalStateException("Not supported on Android")
|
|
741
753
|
}
|
|
742
754
|
}
|
|
743
755
|
|
|
744
756
|
@ReactMethod
|
|
745
757
|
override fun liveActivityEnd(request: ReadableMap?, promise: Promise) {
|
|
746
|
-
promise.
|
|
758
|
+
promise.resolve(scope) {
|
|
747
759
|
throw IllegalStateException("Not supported on Android")
|
|
748
760
|
}
|
|
749
761
|
}
|
|
750
762
|
|
|
751
763
|
@ReactMethod
|
|
752
764
|
override fun liveUpdateListAll(promise: Promise) {
|
|
753
|
-
promise.
|
|
754
|
-
proxy.liveUpdateManager.listAll()
|
|
755
|
-
JsonValue.wrapOpt(it)
|
|
756
|
-
}
|
|
765
|
+
promise.resolve(scope) {
|
|
766
|
+
proxy.liveUpdateManager.listAll()
|
|
757
767
|
}
|
|
758
768
|
}
|
|
759
769
|
|
|
760
770
|
@ReactMethod
|
|
761
771
|
override fun liveUpdateList(request: ReadableMap?, promise: Promise) {
|
|
762
|
-
promise.
|
|
772
|
+
promise.resolve(scope) {
|
|
763
773
|
proxy.liveUpdateManager.list(
|
|
764
774
|
LiveUpdateRequest.List.fromJson(Utils.convertMap(requireNotNull(request)).toJsonValue())
|
|
765
|
-
)
|
|
766
|
-
JsonValue.wrapOpt(it)
|
|
767
|
-
}
|
|
775
|
+
)
|
|
768
776
|
}
|
|
769
777
|
}
|
|
770
778
|
|
|
771
779
|
@ReactMethod
|
|
772
780
|
override fun liveUpdateStart(request: ReadableMap?, promise: Promise) {
|
|
773
|
-
promise.
|
|
781
|
+
promise.resolve(scope) {
|
|
774
782
|
proxy.liveUpdateManager.start(
|
|
775
783
|
LiveUpdateRequest.Start.fromJson(Utils.convertMap(requireNotNull(request)).toJsonValue())
|
|
776
784
|
)
|
|
@@ -779,7 +787,7 @@ class AirshipModule internal constructor(val context: ReactApplicationContext) :
|
|
|
779
787
|
|
|
780
788
|
@ReactMethod
|
|
781
789
|
override fun liveUpdateUpdate(request: ReadableMap?, promise: Promise) {
|
|
782
|
-
promise.
|
|
790
|
+
promise.resolve(scope) {
|
|
783
791
|
proxy.liveUpdateManager.update(
|
|
784
792
|
LiveUpdateRequest.Update.fromJson(Utils.convertMap(requireNotNull(request)).toJsonValue())
|
|
785
793
|
)
|
|
@@ -788,7 +796,7 @@ class AirshipModule internal constructor(val context: ReactApplicationContext) :
|
|
|
788
796
|
|
|
789
797
|
@ReactMethod
|
|
790
798
|
override fun liveUpdateEnd(request: ReadableMap?, promise: Promise) {
|
|
791
|
-
promise.
|
|
799
|
+
promise.resolve(scope) {
|
|
792
800
|
proxy.liveUpdateManager.end(
|
|
793
801
|
LiveUpdateRequest.End.fromJson(Utils.convertMap(requireNotNull(request)).toJsonValue())
|
|
794
802
|
)
|
|
@@ -797,7 +805,7 @@ class AirshipModule internal constructor(val context: ReactApplicationContext) :
|
|
|
797
805
|
|
|
798
806
|
@ReactMethod
|
|
799
807
|
override fun liveUpdateClearAll(promise: Promise) {
|
|
800
|
-
promise.
|
|
808
|
+
promise.resolve(scope) {
|
|
801
809
|
proxy.liveUpdateManager.clearAll()
|
|
802
810
|
}
|
|
803
811
|
}
|
|
@@ -826,68 +834,26 @@ internal fun JsonSerializable.toReactType(): Any? {
|
|
|
826
834
|
return Utils.convertJsonValue(toJsonValue())
|
|
827
835
|
}
|
|
828
836
|
|
|
829
|
-
internal fun Promise.resolveResult(function: () -> Any?) {
|
|
830
|
-
resolveDeferred<Any> { callback -> callback(function(), null) }
|
|
831
|
-
}
|
|
832
837
|
|
|
833
|
-
internal fun Promise.
|
|
838
|
+
internal fun Promise.resolve(scope: CoroutineScope, function: suspend () -> Any?) {
|
|
834
839
|
scope.launch {
|
|
835
840
|
try {
|
|
836
841
|
when (val result = function()) {
|
|
837
842
|
is Unit -> {
|
|
838
|
-
this@
|
|
843
|
+
this@resolve.resolve(null)
|
|
839
844
|
}
|
|
840
845
|
is JsonSerializable -> {
|
|
841
|
-
this@
|
|
846
|
+
this@resolve.resolve(result.toReactType())
|
|
842
847
|
}
|
|
843
848
|
is Number -> {
|
|
844
|
-
this@
|
|
849
|
+
this@resolve.resolve(result.toDouble())
|
|
845
850
|
}
|
|
846
851
|
else -> {
|
|
847
|
-
this@
|
|
852
|
+
this@resolve.resolve(JsonValue.wrapOpt(result).toReactType())
|
|
848
853
|
}
|
|
849
854
|
}
|
|
850
855
|
} catch (e: Exception) {
|
|
851
|
-
this@
|
|
852
|
-
}
|
|
853
|
-
}
|
|
854
|
-
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
internal fun <T> Promise.resolveDeferred(function: ((T?, Exception?) -> Unit) -> Unit) {
|
|
858
|
-
try {
|
|
859
|
-
function { result, error ->
|
|
860
|
-
if (error != null) {
|
|
861
|
-
this.reject("AIRSHIP_ERROR", error)
|
|
862
|
-
}
|
|
863
|
-
try {
|
|
864
|
-
when (result) {
|
|
865
|
-
is Unit -> {
|
|
866
|
-
this.resolve(null)
|
|
867
|
-
}
|
|
868
|
-
is JsonSerializable -> {
|
|
869
|
-
this.resolve(result.toReactType())
|
|
870
|
-
}
|
|
871
|
-
is Number -> {
|
|
872
|
-
this.resolve((result as Number).toDouble())
|
|
873
|
-
}
|
|
874
|
-
else -> {
|
|
875
|
-
this.resolve(result)
|
|
876
|
-
}
|
|
877
|
-
}
|
|
878
|
-
} catch (e: Exception) {
|
|
879
|
-
this.reject("AIRSHIP_ERROR", e)
|
|
880
|
-
}
|
|
881
|
-
}
|
|
882
|
-
} catch (e: Exception) {
|
|
883
|
-
this.reject("AIRSHIP_ERROR", e)
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
|
|
887
|
-
internal fun <T> Promise.resolvePending(function: () -> PendingResult<T>) {
|
|
888
|
-
resolveDeferred<T> { callback ->
|
|
889
|
-
function().addResultCallback {
|
|
890
|
-
callback(it, null)
|
|
856
|
+
this@resolve.reject("AIRSHIP_ERROR", e)
|
|
891
857
|
}
|
|
892
858
|
}
|
|
893
859
|
}
|