@altcraft/react-native-sdk 0.0.1 → 0.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/altcraft/sdk/SdkModule.kt +53 -529
- package/android/src/main/java/com/altcraft/sdk/interfaces/RnFCMProvider.kt +0 -1
- package/android/src/main/java/com/altcraft/sdk/utilities/Converter.kt +162 -0
- package/ios/Converter.swift +203 -0
- package/ios/Sdk.h +4 -3
- package/ios/Sdk.mm +74 -132
- package/ios/SdkModule.swift +260 -319
- package/lib/module/NativeSdk.js.map +1 -1
- package/lib/module/index.js +124 -341
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/NativeSdk.d.ts +11 -2
- package/lib/typescript/src/NativeSdk.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +69 -332
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/NativeSdk.ts +25 -6
- package/src/index.tsx +170 -368
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
package com.altcraft.sdk
|
|
2
2
|
|
|
3
3
|
import androidx.activity.ComponentActivity
|
|
4
|
-
import com.altcraft.sdk.AltcraftSDK
|
|
5
4
|
import com.altcraft.sdk.config.AltcraftConfiguration
|
|
6
5
|
import com.altcraft.sdk.data.DataClasses
|
|
7
6
|
import com.altcraft.sdk.mob_events.PublicMobileEventFunction
|
|
@@ -13,13 +12,14 @@ import com.altcraft.sdk.rn.providers.RnHMSProvider
|
|
|
13
12
|
import com.altcraft.sdk.rn.providers.RnJWTProvider
|
|
14
13
|
import com.altcraft.sdk.rn.providers.RnRuStoreProvider
|
|
15
14
|
import com.altcraft.sdk.sdk_events.Events
|
|
15
|
+
import com.altcraft.sdk.utilities.Converter
|
|
16
16
|
import com.facebook.react.bridge.Arguments
|
|
17
17
|
import com.facebook.react.bridge.Promise
|
|
18
18
|
import com.facebook.react.bridge.ReactApplicationContext
|
|
19
19
|
import com.facebook.react.bridge.ReadableArray
|
|
20
20
|
import com.facebook.react.bridge.ReadableMap
|
|
21
|
-
import com.facebook.react.bridge.WritableMap
|
|
22
21
|
import com.facebook.react.bridge.UiThreadUtil
|
|
22
|
+
import com.facebook.react.bridge.WritableMap
|
|
23
23
|
import com.facebook.react.module.annotations.ReactModule
|
|
24
24
|
import com.facebook.react.modules.core.DeviceEventManagerModule.RCTDeviceEventEmitter
|
|
25
25
|
import kotlinx.coroutines.CoroutineScope
|
|
@@ -27,49 +27,17 @@ import kotlinx.coroutines.Dispatchers
|
|
|
27
27
|
import kotlinx.coroutines.SupervisorJob
|
|
28
28
|
import kotlinx.coroutines.launch
|
|
29
29
|
|
|
30
|
-
/**
|
|
31
|
-
* React Native bridge module for Altcraft Android SDK.
|
|
32
|
-
*
|
|
33
|
-
* Responsibilities:
|
|
34
|
-
* - Initializes the SDK from JS configuration.
|
|
35
|
-
* - Provides token/auth providers (JWT, FCM, HMS, RuStore).
|
|
36
|
-
* - Exposes push token API (get/set/delete/force update).
|
|
37
|
-
* - Bridges subscription calls and async status methods.
|
|
38
|
-
* - Emits SDK events to JS via DeviceEventEmitter ("AltcraftSdkEvent").
|
|
39
|
-
*
|
|
40
|
-
* Threading:
|
|
41
|
-
* - Async / I/O methods are executed on [Dispatchers.IO].
|
|
42
|
-
* - Some SDK callbacks are marshalled back to the UI queue when required.
|
|
43
|
-
*/
|
|
44
30
|
@ReactModule(name = SdkModule.NAME)
|
|
45
31
|
class SdkModule(
|
|
46
32
|
reactContext: ReactApplicationContext
|
|
47
33
|
) : NativeSdkSpec(reactContext) {
|
|
48
34
|
|
|
49
|
-
/**
|
|
50
|
-
* Background scope for bridge calls that must not block JS thread.
|
|
51
|
-
*
|
|
52
|
-
* Note: lifecycle is bound to the module instance. If you later add teardown,
|
|
53
|
-
* cancel this scope accordingly.
|
|
54
|
-
*/
|
|
55
35
|
private val coroutineScope = CoroutineScope(SupervisorJob() + Dispatchers.IO)
|
|
56
36
|
|
|
57
37
|
override fun getName(): String = NAME
|
|
58
38
|
|
|
59
39
|
// ---------------------- init / auth / providers ----------------------
|
|
60
40
|
|
|
61
|
-
/**
|
|
62
|
-
* Initializes Altcraft SDK with configuration provided from React Native.
|
|
63
|
-
*
|
|
64
|
-
* Expected behavior:
|
|
65
|
-
* - Resolves [promise] with `null` on success.
|
|
66
|
-
* - Rejects [promise] with:
|
|
67
|
-
* - ALTCRAFT_INIT_INVALID_CONFIG — if config mapping failed/invalid.
|
|
68
|
-
* - ALTCRAFT_INIT_ERROR — if SDK initialization returned failure.
|
|
69
|
-
*
|
|
70
|
-
* Threading:
|
|
71
|
-
* - SDK init callback is marshalled to UI queue before resolving/rejecting.
|
|
72
|
-
*/
|
|
73
41
|
override fun initialize(config: ReadableMap, promise: Promise) {
|
|
74
42
|
AltcraftRnInitializer.initialize(
|
|
75
43
|
reactApplicationContext,
|
|
@@ -78,18 +46,6 @@ class SdkModule(
|
|
|
78
46
|
)
|
|
79
47
|
}
|
|
80
48
|
|
|
81
|
-
/**
|
|
82
|
-
* Sets JWT token for requests performed by Altcraft SDK.
|
|
83
|
-
*
|
|
84
|
-
* If [token] is null/blank:
|
|
85
|
-
* - Clears RN provider state and disables JWT provider in the SDK.
|
|
86
|
-
*
|
|
87
|
-
* If [token] is provided:
|
|
88
|
-
* - Stores token in RN provider and registers it in the SDK.
|
|
89
|
-
*
|
|
90
|
-
* Notes:
|
|
91
|
-
* - This method is synchronous and safe to call multiple times.
|
|
92
|
-
*/
|
|
93
49
|
override fun setJwt(token: String?) {
|
|
94
50
|
if (token.isNullOrBlank()) {
|
|
95
51
|
RnJWTProvider.clear()
|
|
@@ -100,15 +56,6 @@ class SdkModule(
|
|
|
100
56
|
}
|
|
101
57
|
}
|
|
102
58
|
|
|
103
|
-
/**
|
|
104
|
-
* Sets FCM token for Android push provider.
|
|
105
|
-
*
|
|
106
|
-
* If [token] is null/blank:
|
|
107
|
-
* - Clears provider state and unregisters provider from SDK.
|
|
108
|
-
*
|
|
109
|
-
* If [token] is provided:
|
|
110
|
-
* - Stores token and registers provider in SDK push token functions.
|
|
111
|
-
*/
|
|
112
59
|
override fun setAndroidFcmToken(token: String?) {
|
|
113
60
|
if (token.isNullOrBlank()) {
|
|
114
61
|
RnFCMProvider.clear()
|
|
@@ -119,24 +66,10 @@ class SdkModule(
|
|
|
119
66
|
}
|
|
120
67
|
}
|
|
121
68
|
|
|
122
|
-
/**
|
|
123
|
-
* iOS-only API. No-op on Android.
|
|
124
|
-
*
|
|
125
|
-
* Exists to keep the RN Spec platform-agnostic.
|
|
126
|
-
*/
|
|
127
69
|
override fun setIosFcmToken(token: String?) {
|
|
128
70
|
// no-op on Android
|
|
129
71
|
}
|
|
130
72
|
|
|
131
|
-
/**
|
|
132
|
-
* Sets HMS token for Android push provider.
|
|
133
|
-
*
|
|
134
|
-
* If [token] is null/blank:
|
|
135
|
-
* - Clears provider state and unregisters provider from SDK.
|
|
136
|
-
*
|
|
137
|
-
* If [token] is provided:
|
|
138
|
-
* - Stores token and registers provider in SDK push token functions.
|
|
139
|
-
*/
|
|
140
73
|
override fun setAndroidHmsToken(token: String?) {
|
|
141
74
|
if (token.isNullOrBlank()) {
|
|
142
75
|
RnHMSProvider.clear()
|
|
@@ -147,33 +80,18 @@ class SdkModule(
|
|
|
147
80
|
}
|
|
148
81
|
}
|
|
149
82
|
|
|
150
|
-
/**
|
|
151
|
-
* iOS-only API. No-op on Android.
|
|
152
|
-
*
|
|
153
|
-
* Exists to keep the RN Spec platform-agnostic.
|
|
154
|
-
*/
|
|
155
83
|
override fun setIosHmsToken(token: String?) {
|
|
156
84
|
// no-op on Android
|
|
157
85
|
}
|
|
158
86
|
|
|
159
|
-
/**
|
|
160
|
-
* iOS-only API. No-op on Android.
|
|
161
|
-
*
|
|
162
|
-
* Exists to keep the RN Spec platform-agnostic.
|
|
163
|
-
*/
|
|
164
87
|
override fun setApnsToken(token: String?) {
|
|
165
88
|
// no-op on Android
|
|
166
89
|
}
|
|
167
90
|
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
* - Clears provider state and unregisters provider from SDK.
|
|
173
|
-
*
|
|
174
|
-
* If [token] is provided:
|
|
175
|
-
* - Stores token and registers provider in SDK push token functions.
|
|
176
|
-
*/
|
|
91
|
+
override fun setUserDefaultsValue(suiteName: String?, key: String, value: String?) {
|
|
92
|
+
// no-op on Android
|
|
93
|
+
}
|
|
94
|
+
|
|
177
95
|
override fun setRustoreToken(token: String?) {
|
|
178
96
|
if (token.isNullOrBlank()) {
|
|
179
97
|
RnRuStoreProvider.clear()
|
|
@@ -186,40 +104,16 @@ class SdkModule(
|
|
|
186
104
|
|
|
187
105
|
// ---------------------- required for NativeEventEmitter ----------------------
|
|
188
106
|
|
|
189
|
-
/**
|
|
190
|
-
* React Native requires this method when JS uses NativeEventEmitter.
|
|
191
|
-
*
|
|
192
|
-
* RN may call it when JS adds a listener for a given [eventName].
|
|
193
|
-
* We don't need native-side bookkeeping here because we manage SDK subscription
|
|
194
|
-
* explicitly via [subscribeToEvents]/[unsubscribeFromEvent].
|
|
195
|
-
*/
|
|
196
107
|
override fun addListener(eventName: String) {
|
|
197
108
|
// no-op
|
|
198
109
|
}
|
|
199
110
|
|
|
200
|
-
/**
|
|
201
|
-
* React Native requires this method when JS uses NativeEventEmitter.
|
|
202
|
-
*
|
|
203
|
-
* RN may call it to notify native side that [count] listeners were removed.
|
|
204
|
-
* We keep it as no-op for symmetry with [addListener].
|
|
205
|
-
*/
|
|
206
111
|
override fun removeListeners(count: Double) {
|
|
207
112
|
// no-op
|
|
208
113
|
}
|
|
209
114
|
|
|
210
115
|
// ---------------------- token-API for RN ----------------------
|
|
211
116
|
|
|
212
|
-
/**
|
|
213
|
-
* Returns current push token resolved by Altcraft SDK (if available).
|
|
214
|
-
*
|
|
215
|
-
* Promise:
|
|
216
|
-
* - resolves `null` if token is not available yet;
|
|
217
|
-
* - resolves `{ provider: string, token: string }` if available;
|
|
218
|
-
* - rejects on unexpected errors.
|
|
219
|
-
*
|
|
220
|
-
* Threading:
|
|
221
|
-
* - executed on IO dispatcher.
|
|
222
|
-
*/
|
|
223
117
|
override fun getPushToken(promise: Promise) {
|
|
224
118
|
coroutineScope.launch {
|
|
225
119
|
try {
|
|
@@ -238,20 +132,6 @@ class SdkModule(
|
|
|
238
132
|
}
|
|
239
133
|
}
|
|
240
134
|
|
|
241
|
-
/**
|
|
242
|
-
* Deletes device token for a specific provider on backend (and/or local SDK state,
|
|
243
|
-
* depending on SDK implementation).
|
|
244
|
-
*
|
|
245
|
-
* Params:
|
|
246
|
-
* - [provider] — provider identifier (e.g. "fcm", "hms", "rustore").
|
|
247
|
-
*
|
|
248
|
-
* Promise:
|
|
249
|
-
* - resolves `null` on success;
|
|
250
|
-
* - rejects if [provider] is null or request fails.
|
|
251
|
-
*
|
|
252
|
-
* Threading:
|
|
253
|
-
* - executed on IO dispatcher.
|
|
254
|
-
*/
|
|
255
135
|
override fun deleteDeviceToken(provider: String?, promise: Promise) {
|
|
256
136
|
val p: String = provider ?: run {
|
|
257
137
|
promise.reject("deleteDeviceToken", "provider is null")
|
|
@@ -268,16 +148,6 @@ class SdkModule(
|
|
|
268
148
|
}
|
|
269
149
|
}
|
|
270
150
|
|
|
271
|
-
/**
|
|
272
|
-
* Forces push token update flow in the SDK.
|
|
273
|
-
*
|
|
274
|
-
* Promise:
|
|
275
|
-
* - resolves `null` when update flow completes (SDK callback).
|
|
276
|
-
* - rejects on unexpected errors.
|
|
277
|
-
*
|
|
278
|
-
* Threading:
|
|
279
|
-
* - executed on IO dispatcher.
|
|
280
|
-
*/
|
|
281
151
|
override fun forcedTokenUpdate(promise: Promise) {
|
|
282
152
|
coroutineScope.launch {
|
|
283
153
|
try {
|
|
@@ -290,21 +160,8 @@ class SdkModule(
|
|
|
290
160
|
}
|
|
291
161
|
}
|
|
292
162
|
|
|
293
|
-
/**
|
|
294
|
-
* Updates push provider priority list (order of providers to be used/preferred).
|
|
295
|
-
*
|
|
296
|
-
* Params:
|
|
297
|
-
* - [priorityList] — array of provider ids in desired order.
|
|
298
|
-
*
|
|
299
|
-
* Promise:
|
|
300
|
-
* - resolves `null` on success;
|
|
301
|
-
* - rejects on failure.
|
|
302
|
-
*
|
|
303
|
-
* Threading:
|
|
304
|
-
* - executed on IO dispatcher.
|
|
305
|
-
*/
|
|
306
163
|
override fun changePushProviderPriorityList(priorityList: ReadableArray?, promise: Promise) {
|
|
307
|
-
val list =
|
|
164
|
+
val list = Converter.toStringList(priorityList)
|
|
308
165
|
coroutineScope.launch {
|
|
309
166
|
try {
|
|
310
167
|
PublicPushTokenFunctions.changePushProviderPriorityList(
|
|
@@ -318,22 +175,6 @@ class SdkModule(
|
|
|
318
175
|
}
|
|
319
176
|
}
|
|
320
177
|
|
|
321
|
-
/**
|
|
322
|
-
* Sets or clears push token for a specific provider.
|
|
323
|
-
*
|
|
324
|
-
* JS Spec: setPushToken(provider: string, token: string | null): Promise<void>
|
|
325
|
-
*
|
|
326
|
-
* Behavior:
|
|
327
|
-
* - if [token] == null -> treated as "clear token" and calls deleteDeviceToken(provider)
|
|
328
|
-
* - if [token] != null -> calls setPushToken(provider, token)
|
|
329
|
-
*
|
|
330
|
-
* Promise:
|
|
331
|
-
* - resolves `null` on success;
|
|
332
|
-
* - rejects on invalid provider or request failures.
|
|
333
|
-
*
|
|
334
|
-
* Threading:
|
|
335
|
-
* - executed on IO dispatcher.
|
|
336
|
-
*/
|
|
337
178
|
override fun setPushToken(provider: String, token: String?, promise: Promise) {
|
|
338
179
|
if (provider.isBlank()) {
|
|
339
180
|
promise.reject("setPushToken", "provider is blank")
|
|
@@ -363,15 +204,8 @@ class SdkModule(
|
|
|
363
204
|
}
|
|
364
205
|
}
|
|
365
206
|
|
|
366
|
-
// ---------------------- AltcraftSDK: clear /
|
|
207
|
+
// ---------------------- AltcraftSDK: clear / initial ops / permission ----------------------
|
|
367
208
|
|
|
368
|
-
/**
|
|
369
|
-
* Clears SDK local state (tokens/subscriptions/cache depending on SDK implementation).
|
|
370
|
-
*
|
|
371
|
-
* Promise:
|
|
372
|
-
* - resolves `null` on success;
|
|
373
|
-
* - rejects on unexpected errors.
|
|
374
|
-
*/
|
|
375
209
|
override fun clear(promise: Promise) {
|
|
376
210
|
try {
|
|
377
211
|
AltcraftSDK.clear(reactApplicationContext) {
|
|
@@ -382,31 +216,13 @@ class SdkModule(
|
|
|
382
216
|
}
|
|
383
217
|
}
|
|
384
218
|
|
|
385
|
-
|
|
386
|
-
* Reinitializes retry control for current session.
|
|
387
|
-
*
|
|
388
|
-
* Intended use:
|
|
389
|
-
* - allows SDK to reset retry counters/logic without full re-init.
|
|
390
|
-
*
|
|
391
|
-
* Notes:
|
|
392
|
-
* - swallow exceptions by design (bridge safety).
|
|
393
|
-
*/
|
|
394
|
-
override fun reinitializeRetryControlInThisSession() {
|
|
219
|
+
override fun unlockInitOperationsInThisSession() {
|
|
395
220
|
try {
|
|
396
|
-
AltcraftSDK.
|
|
221
|
+
AltcraftSDK.unlockInitOperationsInThisSession()
|
|
397
222
|
} catch (_: Exception) {
|
|
398
223
|
}
|
|
399
224
|
}
|
|
400
225
|
|
|
401
|
-
/**
|
|
402
|
-
* Requests Android notification permission (where applicable).
|
|
403
|
-
*
|
|
404
|
-
* Requirements:
|
|
405
|
-
* - [currentActivity] must be a [ComponentActivity], otherwise this is no-op.
|
|
406
|
-
*
|
|
407
|
-
* Threading:
|
|
408
|
-
* - permission request is executed on UI thread.
|
|
409
|
-
*/
|
|
410
226
|
override fun requestNotificationPermission() {
|
|
411
227
|
val activity = currentActivity
|
|
412
228
|
if (activity !is ComponentActivity) {
|
|
@@ -425,22 +241,6 @@ class SdkModule(
|
|
|
425
241
|
|
|
426
242
|
// ---------------------- MobileEvent bridge ----------------------
|
|
427
243
|
|
|
428
|
-
/**
|
|
429
|
-
* Sends a mobile event to Altcraft backend via SDK.
|
|
430
|
-
*
|
|
431
|
-
* Params:
|
|
432
|
-
* - [sid] — session/subscribe identifier (SDK-specific).
|
|
433
|
-
* - [eventName] — event name.
|
|
434
|
-
* - [sendMessageId] — optional message id to link event with campaign.
|
|
435
|
-
* - [payload] — event payload.
|
|
436
|
-
* - [matching] — matching fields.
|
|
437
|
-
* - [matchingType] — matching strategy/type (SDK-specific).
|
|
438
|
-
* - [profileFields] — profile fields to attach/update.
|
|
439
|
-
*
|
|
440
|
-
* Notes:
|
|
441
|
-
* - `subscription` and `utm` are not supported in RN bridge yet (sent as null).
|
|
442
|
-
* - exceptions are swallowed by design to keep JS bridge stable.
|
|
443
|
-
*/
|
|
444
244
|
override fun mobileEvent(
|
|
445
245
|
sid: String,
|
|
446
246
|
eventName: String,
|
|
@@ -448,20 +248,32 @@ class SdkModule(
|
|
|
448
248
|
payload: ReadableMap?,
|
|
449
249
|
matching: ReadableMap?,
|
|
450
250
|
matchingType: String?,
|
|
451
|
-
profileFields: ReadableMap
|
|
251
|
+
profileFields: ReadableMap?,
|
|
252
|
+
utm: ReadableMap?
|
|
452
253
|
) {
|
|
453
254
|
try {
|
|
255
|
+
val utmData = utm?.let {
|
|
256
|
+
DataClasses.UTM(
|
|
257
|
+
campaign = it.getString("campaign"),
|
|
258
|
+
content = it.getString("content"),
|
|
259
|
+
keyword = it.getString("keyword"),
|
|
260
|
+
medium = it.getString("medium"),
|
|
261
|
+
source = it.getString("source"),
|
|
262
|
+
temp = it.getString("temp")
|
|
263
|
+
)
|
|
264
|
+
}
|
|
265
|
+
|
|
454
266
|
PublicMobileEventFunction.mobileEvent(
|
|
455
267
|
context = reactApplicationContext,
|
|
456
268
|
sid = sid,
|
|
457
269
|
eventName = eventName,
|
|
458
270
|
sendMessageId = sendMessageId,
|
|
459
|
-
payload =
|
|
460
|
-
matching =
|
|
271
|
+
payload = Converter.toKotlinMap(payload),
|
|
272
|
+
matching = Converter.toKotlinMap(matching),
|
|
461
273
|
matchingType = matchingType,
|
|
462
|
-
profileFields =
|
|
274
|
+
profileFields = Converter.toKotlinMap(profileFields),
|
|
463
275
|
subscription = null,
|
|
464
|
-
utm =
|
|
276
|
+
utm = utmData
|
|
465
277
|
)
|
|
466
278
|
} catch (_: Exception) {
|
|
467
279
|
}
|
|
@@ -469,49 +281,17 @@ class SdkModule(
|
|
|
469
281
|
|
|
470
282
|
// ---------------------- push payload bridge ----------------------
|
|
471
283
|
|
|
472
|
-
/**
|
|
473
|
-
* Passes raw push payload to SDK for parsing/processing.
|
|
474
|
-
*
|
|
475
|
-
* Input:
|
|
476
|
-
* - [message] is a map of string key/value pairs (RN side object).
|
|
477
|
-
*
|
|
478
|
-
* Behavior:
|
|
479
|
-
* - converts [ReadableMap] into Map<String, String> and forwards it into SDK receiver.
|
|
480
|
-
* - if [message] is null or results in empty map — no-op.
|
|
481
|
-
*/
|
|
482
284
|
override fun takePush(message: ReadableMap?) {
|
|
483
285
|
if (message == null) return
|
|
484
|
-
|
|
485
|
-
val map = mutableMapOf<String, String>()
|
|
486
|
-
val iterator = message.keySetIterator()
|
|
487
|
-
while (iterator.hasNextKey()) {
|
|
488
|
-
val key = iterator.nextKey()
|
|
489
|
-
if (!message.isNull(key)) {
|
|
490
|
-
val value = message.getString(key)
|
|
491
|
-
if (value != null) {
|
|
492
|
-
map[key] = value
|
|
493
|
-
}
|
|
494
|
-
}
|
|
495
|
-
}
|
|
496
|
-
|
|
286
|
+
val map = Converter.toStringMapOrNull(message) ?: return
|
|
497
287
|
if (map.isNotEmpty()) {
|
|
498
288
|
AltcraftSDK.PushReceiver.takePush(reactApplicationContext, map)
|
|
499
289
|
}
|
|
500
290
|
}
|
|
501
291
|
|
|
502
|
-
/**
|
|
503
|
-
* Sends push delivery event (SDK analytics/track).
|
|
504
|
-
*
|
|
505
|
-
* Params:
|
|
506
|
-
* - [message] — raw push payload as map (string key/value).
|
|
507
|
-
* - [messageUID] — optional unique message id.
|
|
508
|
-
*
|
|
509
|
-
* Notes:
|
|
510
|
-
* - Exceptions are swallowed to avoid breaking JS flow.
|
|
511
|
-
*/
|
|
512
292
|
override fun deliveryEvent(message: ReadableMap?, messageUID: String?) {
|
|
513
293
|
try {
|
|
514
|
-
val map =
|
|
294
|
+
val map = Converter.toStringMapOrNull(message)
|
|
515
295
|
PublicPushEventFunctions.deliveryEvent(
|
|
516
296
|
context = reactApplicationContext,
|
|
517
297
|
message = map,
|
|
@@ -521,19 +301,9 @@ class SdkModule(
|
|
|
521
301
|
}
|
|
522
302
|
}
|
|
523
303
|
|
|
524
|
-
/**
|
|
525
|
-
* Sends push open event (SDK analytics/track).
|
|
526
|
-
*
|
|
527
|
-
* Params:
|
|
528
|
-
* - [message] — raw push payload as map (string key/value).
|
|
529
|
-
* - [messageUID] — optional unique message id.
|
|
530
|
-
*
|
|
531
|
-
* Notes:
|
|
532
|
-
* - Exceptions are swallowed to avoid breaking JS flow.
|
|
533
|
-
*/
|
|
534
304
|
override fun openEvent(message: ReadableMap?, messageUID: String?) {
|
|
535
305
|
try {
|
|
536
|
-
val map =
|
|
306
|
+
val map = Converter.toStringMapOrNull(message)
|
|
537
307
|
PublicPushEventFunctions.openEvent(
|
|
538
308
|
context = reactApplicationContext,
|
|
539
309
|
message = map,
|
|
@@ -545,39 +315,14 @@ class SdkModule(
|
|
|
545
315
|
|
|
546
316
|
// --------------------- Events bridge for RN ---------------------
|
|
547
317
|
|
|
548
|
-
/**
|
|
549
|
-
* Subscribes to SDK events and forwards them to JS.
|
|
550
|
-
*
|
|
551
|
-
* JS side listens to:
|
|
552
|
-
* - event name: "AltcraftSdkEvent"
|
|
553
|
-
* - payload: { function, code?, message, value?, type }
|
|
554
|
-
*
|
|
555
|
-
* Notes:
|
|
556
|
-
* - For multiple subscriptions from JS, use JS-side guard (your TS already does it).
|
|
557
|
-
*/
|
|
558
318
|
override fun subscribeToEvents() {
|
|
559
319
|
Events.subscribe { event -> sendEventToJs(event) }
|
|
560
320
|
}
|
|
561
321
|
|
|
562
|
-
/**
|
|
563
|
-
* Unsubscribes from SDK event stream.
|
|
564
|
-
*
|
|
565
|
-
* This stops forwarding events to JS.
|
|
566
|
-
*/
|
|
567
322
|
override fun unsubscribeFromEvent() {
|
|
568
323
|
Events.unsubscribe()
|
|
569
324
|
}
|
|
570
325
|
|
|
571
|
-
/**
|
|
572
|
-
* Converts SDK event model to React Native friendly payload and emits it to JS.
|
|
573
|
-
*
|
|
574
|
-
* Payload schema:
|
|
575
|
-
* - function: String
|
|
576
|
-
* - code: Int? (nullable)
|
|
577
|
-
* - message: String
|
|
578
|
-
* - value: Map<String, Any?>? (nullable)
|
|
579
|
-
* - type: "event" | "error" | "retryError"
|
|
580
|
-
*/
|
|
581
326
|
private fun sendEventToJs(event: DataClasses.Event) {
|
|
582
327
|
val eventMap = Arguments.createMap()
|
|
583
328
|
eventMap.putString("function", event.function)
|
|
@@ -624,105 +369,8 @@ class SdkModule(
|
|
|
624
369
|
.emit("AltcraftSdkEvent", eventMap)
|
|
625
370
|
}
|
|
626
371
|
|
|
627
|
-
// --------------------- utils ---------------------
|
|
628
|
-
|
|
629
|
-
/**
|
|
630
|
-
* Converts [ReadableMap] into Kotlin Map or returns null for empty input.
|
|
631
|
-
*/
|
|
632
|
-
private fun ReadableMap?.toMapOrNull(): Map<String, Any?>? {
|
|
633
|
-
if (this == null) return null
|
|
634
|
-
val hash = this.toHashMap()
|
|
635
|
-
return if (hash.isEmpty()) null else hash.toMap()
|
|
636
|
-
}
|
|
637
|
-
|
|
638
|
-
/**
|
|
639
|
-
* Converts RN array of category objects into SDK category list.
|
|
640
|
-
*
|
|
641
|
-
* Returns null for:
|
|
642
|
-
* - null input
|
|
643
|
-
* - empty input
|
|
644
|
-
* - when all items are invalid
|
|
645
|
-
*/
|
|
646
|
-
private fun ReadableArray?.toCategoryListOrNull(): List<DataClasses.CategoryData>? {
|
|
647
|
-
if (this == null || this.size() == 0) return null
|
|
648
|
-
|
|
649
|
-
val result = mutableListOf<DataClasses.CategoryData>()
|
|
650
|
-
for (i in 0 until this.size()) {
|
|
651
|
-
val item = this.getMap(i) ?: continue
|
|
652
|
-
|
|
653
|
-
val name = if (item.hasKey("name") && !item.isNull("name")) item.getString("name") else null
|
|
654
|
-
val title = if (item.hasKey("title") && !item.isNull("title")) item.getString("title") else null
|
|
655
|
-
val steady = if (item.hasKey("steady") && !item.isNull("steady")) item.getBoolean("steady") else null
|
|
656
|
-
val active = if (item.hasKey("active") && !item.isNull("active")) item.getBoolean("active") else null
|
|
657
|
-
|
|
658
|
-
result.add(
|
|
659
|
-
DataClasses.CategoryData(
|
|
660
|
-
name = name,
|
|
661
|
-
title = title,
|
|
662
|
-
steady = steady,
|
|
663
|
-
active = active
|
|
664
|
-
)
|
|
665
|
-
)
|
|
666
|
-
}
|
|
667
|
-
|
|
668
|
-
return if (result.isEmpty()) null else result
|
|
669
|
-
}
|
|
670
|
-
|
|
671
|
-
/**
|
|
672
|
-
* Converts RN string array into Kotlin list.
|
|
673
|
-
*
|
|
674
|
-
* Returns empty list for null/empty input.
|
|
675
|
-
*/
|
|
676
|
-
private fun ReadableArray?.toStringList(): List<String> {
|
|
677
|
-
if (this == null || this.size() == 0) return emptyList()
|
|
678
|
-
|
|
679
|
-
val res = mutableListOf<String>()
|
|
680
|
-
for (i in 0 until this.size()) {
|
|
681
|
-
if (!this.isNull(i)) {
|
|
682
|
-
val v = this.getString(i)
|
|
683
|
-
if (v != null) res.add(v)
|
|
684
|
-
}
|
|
685
|
-
}
|
|
686
|
-
return res
|
|
687
|
-
}
|
|
688
|
-
|
|
689
|
-
/**
|
|
690
|
-
* Converts RN map into Map<String, String>.
|
|
691
|
-
*
|
|
692
|
-
* - Skips null values and non-string values (ReadableMap.getString returns null).
|
|
693
|
-
* - Returns null if map is null or results in empty output.
|
|
694
|
-
*/
|
|
695
|
-
private fun ReadableMap?.toStringMapOrNull(): Map<String, String>? {
|
|
696
|
-
if (this == null) return null
|
|
697
|
-
val iterator = this.keySetIterator()
|
|
698
|
-
if (!iterator.hasNextKey()) return null
|
|
699
|
-
|
|
700
|
-
val result = mutableMapOf<String, String>()
|
|
701
|
-
while (iterator.hasNextKey()) {
|
|
702
|
-
val key = iterator.nextKey()
|
|
703
|
-
if (this.isNull(key)) continue
|
|
704
|
-
val value = this.getString(key)
|
|
705
|
-
if (value != null) {
|
|
706
|
-
result[key] = value
|
|
707
|
-
}
|
|
708
|
-
}
|
|
709
|
-
|
|
710
|
-
return if (result.isEmpty()) null else result.toMap()
|
|
711
|
-
}
|
|
712
|
-
|
|
713
372
|
// --------------------- subscription bridge ---------------------
|
|
714
373
|
|
|
715
|
-
/**
|
|
716
|
-
* Subscribes device/profile for push notifications.
|
|
717
|
-
*
|
|
718
|
-
* Params:
|
|
719
|
-
* - [sync] — if true, performs sync behavior according to SDK rules (defaults to true).
|
|
720
|
-
* - [profileFields] — profile fields for subscription.
|
|
721
|
-
* - [customFields] — custom fields for subscription.
|
|
722
|
-
* - [cats] — categories array.
|
|
723
|
-
* - [replace] — replace existing fields/categories (SDK-specific).
|
|
724
|
-
* - [skipTriggers] — skip triggers (SDK-specific).
|
|
725
|
-
*/
|
|
726
374
|
override fun pushSubscribe(
|
|
727
375
|
sync: Boolean?,
|
|
728
376
|
profileFields: ReadableMap?,
|
|
@@ -735,19 +383,14 @@ class SdkModule(
|
|
|
735
383
|
PublicPushSubscriptionFunctions.pushSubscribe(
|
|
736
384
|
context = reactApplicationContext,
|
|
737
385
|
sync = isSync,
|
|
738
|
-
profileFields =
|
|
739
|
-
customFields =
|
|
740
|
-
cats =
|
|
386
|
+
profileFields = Converter.toKotlinMap(profileFields),
|
|
387
|
+
customFields = Converter.toKotlinMap(customFields),
|
|
388
|
+
cats = Converter.toCategoryListOrNull(cats),
|
|
741
389
|
replace = replace,
|
|
742
390
|
skipTriggers = skipTriggers
|
|
743
391
|
)
|
|
744
392
|
}
|
|
745
393
|
|
|
746
|
-
/**
|
|
747
|
-
* Suspends current push subscription (temporarily disables).
|
|
748
|
-
*
|
|
749
|
-
* Params are equivalent to [pushSubscribe].
|
|
750
|
-
*/
|
|
751
394
|
override fun pushSuspend(
|
|
752
395
|
sync: Boolean?,
|
|
753
396
|
profileFields: ReadableMap?,
|
|
@@ -760,19 +403,14 @@ class SdkModule(
|
|
|
760
403
|
PublicPushSubscriptionFunctions.pushSuspend(
|
|
761
404
|
context = reactApplicationContext,
|
|
762
405
|
sync = isSync,
|
|
763
|
-
profileFields =
|
|
764
|
-
customFields =
|
|
765
|
-
cats =
|
|
406
|
+
profileFields = Converter.toKotlinMap(profileFields),
|
|
407
|
+
customFields = Converter.toKotlinMap(customFields),
|
|
408
|
+
cats = Converter.toCategoryListOrNull(cats),
|
|
766
409
|
replace = replace,
|
|
767
410
|
skipTriggers = skipTriggers
|
|
768
411
|
)
|
|
769
412
|
}
|
|
770
413
|
|
|
771
|
-
/**
|
|
772
|
-
* Unsubscribes (disables) current push subscription.
|
|
773
|
-
*
|
|
774
|
-
* Params are equivalent to [pushSubscribe].
|
|
775
|
-
*/
|
|
776
414
|
override fun pushUnSubscribe(
|
|
777
415
|
sync: Boolean?,
|
|
778
416
|
profileFields: ReadableMap?,
|
|
@@ -785,9 +423,9 @@ class SdkModule(
|
|
|
785
423
|
PublicPushSubscriptionFunctions.pushUnSubscribe(
|
|
786
424
|
context = reactApplicationContext,
|
|
787
425
|
sync = isSync,
|
|
788
|
-
profileFields =
|
|
789
|
-
customFields =
|
|
790
|
-
cats =
|
|
426
|
+
profileFields = Converter.toKotlinMap(profileFields),
|
|
427
|
+
customFields = Converter.toKotlinMap(customFields),
|
|
428
|
+
cats = Converter.toCategoryListOrNull(cats),
|
|
791
429
|
replace = replace,
|
|
792
430
|
skipTriggers = skipTriggers
|
|
793
431
|
)
|
|
@@ -795,15 +433,6 @@ class SdkModule(
|
|
|
795
433
|
|
|
796
434
|
// --------------------- async status bridges ---------------------
|
|
797
435
|
|
|
798
|
-
/**
|
|
799
|
-
* Tries to un-suspend push subscription (async request to backend).
|
|
800
|
-
*
|
|
801
|
-
* Promise:
|
|
802
|
-
* - resolves ResponseWithHttpCode mapped to JS object:
|
|
803
|
-
* { httpCode: number|null, response: { ... } | null }
|
|
804
|
-
* - resolves null if SDK returned null
|
|
805
|
-
* - rejects on unexpected errors
|
|
806
|
-
*/
|
|
807
436
|
override fun unSuspendPushSubscription(promise: Promise) {
|
|
808
437
|
coroutineScope.launch {
|
|
809
438
|
try {
|
|
@@ -817,13 +446,6 @@ class SdkModule(
|
|
|
817
446
|
}
|
|
818
447
|
}
|
|
819
448
|
|
|
820
|
-
/**
|
|
821
|
-
* Returns status of the latest subscription operation (async).
|
|
822
|
-
*
|
|
823
|
-
* Promise:
|
|
824
|
-
* - resolves mapped ResponseWithHttpCode or null
|
|
825
|
-
* - rejects on unexpected errors
|
|
826
|
-
*/
|
|
827
449
|
override fun getStatusOfLatestSubscription(promise: Promise) {
|
|
828
450
|
coroutineScope.launch {
|
|
829
451
|
try {
|
|
@@ -837,13 +459,6 @@ class SdkModule(
|
|
|
837
459
|
}
|
|
838
460
|
}
|
|
839
461
|
|
|
840
|
-
/**
|
|
841
|
-
* Returns status of the latest subscription operation for a specific [provider] (async).
|
|
842
|
-
*
|
|
843
|
-
* Promise:
|
|
844
|
-
* - resolves mapped ResponseWithHttpCode or null
|
|
845
|
-
* - rejects on unexpected errors
|
|
846
|
-
*/
|
|
847
462
|
override fun getStatusOfLatestSubscriptionForProvider(
|
|
848
463
|
provider: String?,
|
|
849
464
|
promise: Promise
|
|
@@ -861,13 +476,6 @@ class SdkModule(
|
|
|
861
476
|
}
|
|
862
477
|
}
|
|
863
478
|
|
|
864
|
-
/**
|
|
865
|
-
* Returns status for current subscription (async).
|
|
866
|
-
*
|
|
867
|
-
* Promise:
|
|
868
|
-
* - resolves mapped ResponseWithHttpCode or null
|
|
869
|
-
* - rejects on unexpected errors
|
|
870
|
-
*/
|
|
871
479
|
override fun getStatusForCurrentSubscription(promise: Promise) {
|
|
872
480
|
coroutineScope.launch {
|
|
873
481
|
try {
|
|
@@ -881,29 +489,6 @@ class SdkModule(
|
|
|
881
489
|
}
|
|
882
490
|
}
|
|
883
491
|
|
|
884
|
-
/**
|
|
885
|
-
* Maps SDK [DataClasses.ResponseWithHttpCode] into a JS-friendly [WritableMap].
|
|
886
|
-
*
|
|
887
|
-
* Output schema:
|
|
888
|
-
* - httpCode: Int?
|
|
889
|
-
* - response: {
|
|
890
|
-
* error: Int?,
|
|
891
|
-
* errorText: String?,
|
|
892
|
-
* profile: {
|
|
893
|
-
* id: String?,
|
|
894
|
-
* status: String?,
|
|
895
|
-
* isTest: Boolean?,
|
|
896
|
-
* subscription: {
|
|
897
|
-
* subscriptionId: String?,
|
|
898
|
-
* hashId: String?,
|
|
899
|
-
* provider: String?,
|
|
900
|
-
* status: String?,
|
|
901
|
-
* fields: null,
|
|
902
|
-
* cats: null
|
|
903
|
-
* } | null
|
|
904
|
-
* } | null
|
|
905
|
-
* } | null
|
|
906
|
-
*/
|
|
907
492
|
private fun responseWithHttpCodeToWritableMap(
|
|
908
493
|
data: DataClasses.ResponseWithHttpCode?
|
|
909
494
|
): WritableMap? {
|
|
@@ -1001,7 +586,6 @@ class SdkModule(
|
|
|
1001
586
|
subMap.putNull("status")
|
|
1002
587
|
}
|
|
1003
588
|
|
|
1004
|
-
// Kept as is (reserved for future schema extension).
|
|
1005
589
|
subMap.putNull("fields")
|
|
1006
590
|
subMap.putNull("cats")
|
|
1007
591
|
|
|
@@ -1022,20 +606,9 @@ class SdkModule(
|
|
|
1022
606
|
|
|
1023
607
|
/**
|
|
1024
608
|
* Internal RN initializer entry point.
|
|
1025
|
-
*
|
|
1026
|
-
* Converts RN config -> [AltcraftConfiguration] and performs [AltcraftSDK.initialization].
|
|
1027
|
-
* All errors are mapped into RN Promise rejections with stable error codes.
|
|
1028
609
|
*/
|
|
1029
610
|
internal object AltcraftRnInitializer {
|
|
1030
611
|
|
|
1031
|
-
/**
|
|
1032
|
-
* Initializes Altcraft SDK with mapped configuration.
|
|
1033
|
-
*
|
|
1034
|
-
* Promise contract:
|
|
1035
|
-
* - resolve(null) on success
|
|
1036
|
-
* - reject("ALTCRAFT_INIT_INVALID_CONFIG", ...) if config mapping failed
|
|
1037
|
-
* - reject("ALTCRAFT_INIT_ERROR", ...) if SDK init failed
|
|
1038
|
-
*/
|
|
1039
612
|
fun initialize(
|
|
1040
613
|
reactContext: ReactApplicationContext,
|
|
1041
614
|
config: ReadableMap,
|
|
@@ -1080,19 +653,9 @@ internal object AltcraftRnInitializer {
|
|
|
1080
653
|
|
|
1081
654
|
/**
|
|
1082
655
|
* Maps React Native configuration object to native [AltcraftConfiguration].
|
|
1083
|
-
*
|
|
1084
|
-
* Notes:
|
|
1085
|
-
* - `apiUrl` is required.
|
|
1086
|
-
* - `enableLogging` is nullable to keep SDK default behavior when not provided.
|
|
1087
|
-
* - android-only keys are prefixed with `android_*` so iOS can safely ignore them.
|
|
1088
656
|
*/
|
|
1089
657
|
internal object AltcraftRnConfigMapper {
|
|
1090
658
|
|
|
1091
|
-
/**
|
|
1092
|
-
* Builds native SDK configuration from RN map.
|
|
1093
|
-
*
|
|
1094
|
-
* @throws IllegalArgumentException if required fields are missing or invalid.
|
|
1095
|
-
*/
|
|
1096
659
|
fun buildConfiguration(config: ReadableMap): AltcraftConfiguration {
|
|
1097
660
|
if (!config.hasKey("apiUrl") || config.isNull("apiUrl")) {
|
|
1098
661
|
throw IllegalArgumentException("apiUrl is required for AltcraftConfiguration")
|
|
@@ -1101,8 +664,6 @@ internal object AltcraftRnConfigMapper {
|
|
|
1101
664
|
val apiUrl = config.getString("apiUrl")
|
|
1102
665
|
?: throw IllegalArgumentException("apiUrl must be a non-null string")
|
|
1103
666
|
|
|
1104
|
-
// ---------------- COMMON ----------------
|
|
1105
|
-
|
|
1106
667
|
val rToken: String? =
|
|
1107
668
|
if (config.hasKey("rToken") && !config.isNull("rToken")) {
|
|
1108
669
|
config.getString("rToken")
|
|
@@ -1119,29 +680,17 @@ internal object AltcraftRnConfigMapper {
|
|
|
1119
680
|
val appID =
|
|
1120
681
|
if (appInfoMap.hasKey("appID") && !appInfoMap.isNull("appID")) {
|
|
1121
682
|
appInfoMap.getString("appID") ?: ""
|
|
1122
|
-
} else
|
|
1123
|
-
""
|
|
1124
|
-
}
|
|
1125
|
-
|
|
683
|
+
} else ""
|
|
1126
684
|
val appIID =
|
|
1127
685
|
if (appInfoMap.hasKey("appIID") && !appInfoMap.isNull("appIID")) {
|
|
1128
686
|
appInfoMap.getString("appIID") ?: ""
|
|
1129
|
-
} else
|
|
1130
|
-
""
|
|
1131
|
-
}
|
|
1132
|
-
|
|
687
|
+
} else ""
|
|
1133
688
|
val appVer =
|
|
1134
689
|
if (appInfoMap.hasKey("appVer") && !appInfoMap.isNull("appVer")) {
|
|
1135
690
|
appInfoMap.getString("appVer") ?: ""
|
|
1136
|
-
} else
|
|
1137
|
-
""
|
|
1138
|
-
}
|
|
691
|
+
} else ""
|
|
1139
692
|
|
|
1140
|
-
DataClasses.AppInfo(
|
|
1141
|
-
appID = appID,
|
|
1142
|
-
appIID = appIID,
|
|
1143
|
-
appVer = appVer
|
|
1144
|
-
)
|
|
693
|
+
DataClasses.AppInfo(appID = appID, appIID = appIID, appVer = appVer)
|
|
1145
694
|
}
|
|
1146
695
|
} else {
|
|
1147
696
|
null
|
|
@@ -1151,61 +700,43 @@ internal object AltcraftRnConfigMapper {
|
|
|
1151
700
|
if (config.hasKey("providerPriorityList") && !config.isNull("providerPriorityList")) {
|
|
1152
701
|
val array = config.getArray("providerPriorityList")
|
|
1153
702
|
if (array == null) null else readableStringArrayToList(array)
|
|
1154
|
-
} else
|
|
1155
|
-
null
|
|
1156
|
-
}
|
|
703
|
+
} else null
|
|
1157
704
|
|
|
1158
705
|
val enableLogging: Boolean? =
|
|
1159
706
|
if (config.hasKey("enableLogging") && !config.isNull("enableLogging")) {
|
|
1160
707
|
config.getBoolean("enableLogging")
|
|
1161
|
-
} else
|
|
1162
|
-
null
|
|
1163
|
-
}
|
|
1164
|
-
|
|
1165
|
-
// ---------------- ANDROID-ONLY ----------------
|
|
708
|
+
} else null
|
|
1166
709
|
|
|
1167
710
|
val icon: Int? =
|
|
1168
711
|
if (config.hasKey("android_icon") && !config.isNull("android_icon")) {
|
|
1169
712
|
config.getInt("android_icon")
|
|
1170
|
-
} else
|
|
1171
|
-
null
|
|
1172
|
-
}
|
|
713
|
+
} else null
|
|
1173
714
|
|
|
1174
715
|
val usingService: Boolean =
|
|
1175
716
|
if (config.hasKey("android_usingService") && !config.isNull("android_usingService")) {
|
|
1176
717
|
config.getBoolean("android_usingService")
|
|
1177
|
-
} else
|
|
1178
|
-
false
|
|
1179
|
-
}
|
|
718
|
+
} else false
|
|
1180
719
|
|
|
1181
720
|
val serviceMessage: String? =
|
|
1182
721
|
if (config.hasKey("android_serviceMessage") && !config.isNull("android_serviceMessage")) {
|
|
1183
722
|
config.getString("android_serviceMessage")
|
|
1184
|
-
} else
|
|
1185
|
-
null
|
|
1186
|
-
}
|
|
723
|
+
} else null
|
|
1187
724
|
|
|
1188
725
|
val pushReceiverModules: List<String>? =
|
|
1189
726
|
if (config.hasKey("android_pushReceiverModules") && !config.isNull("android_pushReceiverModules")) {
|
|
1190
727
|
val array = config.getArray("android_pushReceiverModules")
|
|
1191
728
|
if (array == null) null else readableStringArrayToList(array)
|
|
1192
|
-
} else
|
|
1193
|
-
null
|
|
1194
|
-
}
|
|
729
|
+
} else null
|
|
1195
730
|
|
|
1196
731
|
val pushChannelName: String? =
|
|
1197
732
|
if (config.hasKey("android_pushChannelName") && !config.isNull("android_pushChannelName")) {
|
|
1198
733
|
config.getString("android_pushChannelName")
|
|
1199
|
-
} else
|
|
1200
|
-
null
|
|
1201
|
-
}
|
|
734
|
+
} else null
|
|
1202
735
|
|
|
1203
736
|
val pushChannelDescription: String? =
|
|
1204
737
|
if (config.hasKey("android_pushChannelDescription") && !config.isNull("android_pushChannelDescription")) {
|
|
1205
738
|
config.getString("android_pushChannelDescription")
|
|
1206
|
-
} else
|
|
1207
|
-
null
|
|
1208
|
-
}
|
|
739
|
+
} else null
|
|
1209
740
|
|
|
1210
741
|
return AltcraftConfiguration.Builder(
|
|
1211
742
|
apiUrl = apiUrl,
|
|
@@ -1222,21 +753,14 @@ internal object AltcraftRnConfigMapper {
|
|
|
1222
753
|
).build()
|
|
1223
754
|
}
|
|
1224
755
|
|
|
1225
|
-
/**
|
|
1226
|
-
* Converts RN string array into Kotlin list of strings.
|
|
1227
|
-
*
|
|
1228
|
-
* Skips null elements.
|
|
1229
|
-
*/
|
|
1230
756
|
private fun readableStringArrayToList(array: ReadableArray): List<String> {
|
|
1231
757
|
val result = ArrayList<String>()
|
|
1232
758
|
for (i in 0 until array.size()) {
|
|
1233
759
|
if (!array.isNull(i)) {
|
|
1234
760
|
val value = array.getString(i)
|
|
1235
|
-
if (value != null)
|
|
1236
|
-
result.add(value)
|
|
1237
|
-
}
|
|
761
|
+
if (value != null) result.add(value)
|
|
1238
762
|
}
|
|
1239
763
|
}
|
|
1240
764
|
return result
|
|
1241
765
|
}
|
|
1242
|
-
}
|
|
766
|
+
}
|