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