@altcraft/react-native-sdk 0.0.3 → 0.0.4
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/README.md +119 -30
- package/Sdk.podspec +2 -2
- package/android/build.gradle +2 -2
- package/android/src/main/java/com/altcraft/sdk/SdkEventEmitter.kt +50 -0
- package/android/src/main/java/com/altcraft/sdk/SdkModule.kt +122 -12
- package/android/src/main/java/com/altcraft/sdk/SdkPackage.kt +16 -8
- package/ios/Converter.swift +2 -2
- package/ios/Sdk.mm +113 -0
- package/ios/SdkModule.swift +137 -30
- package/lib/module/NativeSdk.js.map +1 -1
- package/lib/module/Utilities.js +84 -0
- package/lib/module/Utilities.js.map +1 -1
- package/lib/module/index.js +141 -29
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/NativeSdk.d.ts +18 -2
- package/lib/typescript/src/NativeSdk.d.ts.map +1 -1
- package/lib/typescript/src/Utilities.d.ts +32 -0
- package/lib/typescript/src/Utilities.d.ts.map +1 -1
- package/lib/typescript/src/index.d.ts +61 -5
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/NativeSdk.ts +34 -2
- package/src/Utilities.ts +66 -2
- package/src/index.tsx +169 -41
package/README.md
CHANGED
|
@@ -2,48 +2,137 @@
|
|
|
2
2
|
|
|
3
3
|

|
|
4
4
|
|
|
5
|
-
[](#)
|
|
5
|
+
[](https://www.npmjs.com/package/react-native-sdk)
|
|
6
|
+
[](https://reactnative.dev/)
|
|
7
|
+
[](#)
|
|
8
|
+
[](#)
|
|
10
9
|
|
|
11
|
-
Altcraft React Native SDK is a bridge to the native **Altcraft Mobile SDK** for Android.
|
|
12
|
-
It helps manage push subscriptions, tokens, SDK events, and sending mobile events to the Altcraft platform.
|
|
13
|
-
|
|
14
|
-
> This README intentionally covers **Android only** (no iOS setup here).
|
|
10
|
+
Altcraft React Native SDK is a bridge to the native **Altcraft Mobile SDK** for Android and iOS. The SDK automates push notification delivery, event submission, request retries, and supports flexible workflows with JWT or role-based tokens.
|
|
15
11
|
|
|
16
12
|
---
|
|
17
13
|
|
|
18
14
|
## Features
|
|
19
15
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
16
|
+
* [x] Compatible with TypeScript and JavaScript.
|
|
17
|
+
* [x] Works with anonymous and registered users; supports multiple profiles on one device (JWT).
|
|
18
|
+
* [x] Push subscription management: push subscribe, push suspend, push unsubscribe.
|
|
19
|
+
* [x] Automatic push token update when it changes.
|
|
20
|
+
* [x] Automatic transmission of notification delivery and open events.
|
|
21
|
+
* [x] Mobile events registration.
|
|
22
|
+
* [x] Update profile fields.
|
|
23
|
+
* [x] Automatic retry of failed requests.
|
|
24
|
+
* [x] Support for push providers: Firebase FCM (Android), APNs (iOS).
|
|
25
|
+
* [x] Secure requests using JWT and flexible identifier matching.
|
|
26
|
+
* [x] Support for rToken for simple subscription scenarios.
|
|
27
|
+
* [x] SDK data cleanup and background tasks termination.
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## Dependency
|
|
32
|
+
|
|
33
|
+
`react-native-sdk:1.0.0`
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Authorization Types
|
|
38
|
+
|
|
39
|
+
### JWT-Authorization (recommended approach)
|
|
40
|
+
|
|
41
|
+
JWT is added to the header of every request. The SDK requests the current token from the app via the `JWTInterface`.
|
|
42
|
+
|
|
43
|
+
**Advantages:**
|
|
44
|
+
|
|
45
|
+
* Enhanced security of API requests.
|
|
46
|
+
* Profile lookup by any identifier (email, phone, custom ID).
|
|
47
|
+
* Support for multiple users on a single device.
|
|
48
|
+
* Profile persists after app reinstallation.
|
|
49
|
+
* Unified user identity across devices.
|
|
50
|
+
|
|
51
|
+
### Authorization with a role token (*rToken*)
|
|
52
|
+
|
|
53
|
+
The role token is specified in the SDK configuration.
|
|
54
|
+
Profile lookup is limited to the push token identifier.
|
|
55
|
+
|
|
56
|
+
**Limitations:**
|
|
57
|
+
|
|
58
|
+
* The link to a profile may be lost if the push token changes and the change isn't reflected on the platform.
|
|
59
|
+
* No multi-profile support.
|
|
60
|
+
* It's not possible to register the same user on another device.
|
|
32
61
|
|
|
33
62
|
---
|
|
34
63
|
|
|
35
64
|
## Requirements
|
|
36
65
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
66
|
+
* React Native 0.70+.
|
|
67
|
+
* Android 7.1+ (API 25).
|
|
68
|
+
* iOS 13.0+.
|
|
69
|
+
* Push provider integrated in the host app (FCM for Android, APNs for iOS).
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## Documentations
|
|
74
|
+
|
|
75
|
+
Detailed information on SDK setup, functionality, and usage is available on the Altcraft documentation portal. You can navigate to the required section using the links below:
|
|
76
|
+
|
|
77
|
+
- [**Quick Start**](https://guides.altcraft.com/en/developer-guide/sdk/mobile/react-native/quick-start)
|
|
78
|
+
- [**SDK Functionality**](https://guides.altcraft.com/en/developer-guide/sdk/mobile/react-native/functionality)
|
|
79
|
+
- [**SDK Configuration**](https://guides.altcraft.com/en/developer-guide/sdk/mobile/react-native/setup)
|
|
80
|
+
- [**Classes and Structures**](https://guides.altcraft.com/en/developer-guide/sdk/mobile/react-native/api)
|
|
81
|
+
|
|
82
|
+
**Provider Setup**
|
|
83
|
+
|
|
84
|
+
- [FCM](https://guides.altcraft.com/en/developer-guide/sdk/mobile/android/providers/fcm/)
|
|
85
|
+
- [APNs](https://guides.altcraft.com/en/developer-guide/sdk/mobile/ios/providers/apns/)
|
|
41
86
|
|
|
42
87
|
---
|
|
43
88
|
|
|
44
|
-
##
|
|
89
|
+
## License
|
|
90
|
+
|
|
91
|
+
### EULA
|
|
92
|
+
|
|
93
|
+
END USER LICENSE AGREEMENT
|
|
94
|
+
|
|
95
|
+
Copyright © 2024 Altcraft LLC. All rights reserved.
|
|
96
|
+
|
|
97
|
+
1. LICENSE GRANT
|
|
98
|
+
This agreement grants you certain rights to use the Altcraft Mobile SDK (hereinafter referred to as the "Software").
|
|
99
|
+
All rights not expressly granted by this agreement remain with the copyright holder.
|
|
100
|
+
|
|
101
|
+
2. USE
|
|
102
|
+
You are permitted to use and distribute the Software for both commercial and non-commercial purposes.
|
|
103
|
+
|
|
104
|
+
3. MODIFICATION WITHOUT PUBLICATION
|
|
105
|
+
You may modify the Software for your own internal purposes without any obligation to publish such modifications.
|
|
106
|
+
|
|
107
|
+
4. MODIFICATION WITH PUBLICATION
|
|
108
|
+
Publication of modified Software requires prior written permission from the copyright holder.
|
|
109
|
+
|
|
110
|
+
5. DISCLAIMER OF WARRANTIES
|
|
111
|
+
The Software is provided "as is," without any warranties, express or implied, including but not limited to
|
|
112
|
+
warranties of merchantability, fitness for a particular purpose, and non-infringement of third-party rights.
|
|
113
|
+
|
|
114
|
+
6. LIMITATION OF LIABILITY
|
|
115
|
+
Under no circumstances shall the copyright holder be liable for any direct, indirect, incidental, special,
|
|
116
|
+
punitive, or consequential damages (including but not limited to: procurement of substitute goods or services;
|
|
117
|
+
loss of data, profits, or business interruption) arising in any way from the use of this Software,
|
|
118
|
+
even if the copyright holder has been advised of the possibility of such damages.
|
|
119
|
+
|
|
120
|
+
7. DISTRIBUTION
|
|
121
|
+
When distributing the Software, you must provide all recipients with a copy of this license agreement.
|
|
122
|
+
|
|
123
|
+
8. COPYRIGHT AND THIRD-PARTY COMPONENTS
|
|
124
|
+
This Software may include components distributed under other licenses. The full list of such components
|
|
125
|
+
and their respective licenses is provided below:
|
|
126
|
+
|
|
127
|
+
### Third-party libraries and licenses
|
|
128
|
+
|
|
129
|
+
**Apache License 2.0**
|
|
130
|
+
Licensed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0).
|
|
131
|
+
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
132
|
+
|
|
133
|
+
* [React Native](https://github.com/facebook/react-native)
|
|
134
|
+
* [TypeScript](https://www.typescriptlang.org/)
|
|
135
|
+
|
|
136
|
+
**MIT License**
|
|
45
137
|
|
|
46
|
-
|
|
47
|
-
yarn add altcraft-react-native-sdk
|
|
48
|
-
# or
|
|
49
|
-
npm i altcraft-react-native-sdk
|
|
138
|
+
* [React](https://github.com/facebook/react)
|
package/Sdk.podspec
CHANGED
|
@@ -22,7 +22,7 @@ Pod::Spec.new do |s|
|
|
|
22
22
|
s.public_header_files = "ios/**/*.h"
|
|
23
23
|
|
|
24
24
|
# --- Swift / Module settings (critical for <Sdk/Sdk-Swift.h>) ---
|
|
25
|
-
s.swift_version = "
|
|
25
|
+
s.swift_version = "6.0"
|
|
26
26
|
s.pod_target_xcconfig = {
|
|
27
27
|
"DEFINES_MODULE" => "YES",
|
|
28
28
|
"CLANG_ENABLE_MODULES" => "YES",
|
|
@@ -30,7 +30,7 @@ Pod::Spec.new do |s|
|
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
# --- Native dependency ---
|
|
33
|
-
s.dependency "Altcraft", "0.
|
|
33
|
+
s.dependency "Altcraft", "1.0.3"
|
|
34
34
|
|
|
35
35
|
# --- React Native module deps ---
|
|
36
36
|
install_modules_dependencies(s)
|
package/android/build.gradle
CHANGED
|
@@ -70,8 +70,8 @@ repositories {
|
|
|
70
70
|
def kotlin_version = getExtOrDefault("kotlinVersion")
|
|
71
71
|
|
|
72
72
|
dependencies {
|
|
73
|
-
api "com.altcraft:android-sdk:1.0.
|
|
73
|
+
api "com.altcraft:android-sdk:1.0.6"
|
|
74
74
|
implementation "com.facebook.react:react-android"
|
|
75
75
|
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
76
76
|
implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3"
|
|
77
|
-
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
package com.altcraft.sdk
|
|
2
|
+
|
|
3
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
4
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
5
|
+
import com.facebook.react.bridge.ReactMethod
|
|
6
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
7
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Event emitter module for NativeEventEmitter on the JS side.
|
|
11
|
+
* SdkModule calls [emit] to forward SDK events to JS.
|
|
12
|
+
*/
|
|
13
|
+
@ReactModule(name = SdkEventEmitter.NAME)
|
|
14
|
+
class SdkEventEmitter(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
|
|
15
|
+
|
|
16
|
+
companion object {
|
|
17
|
+
const val NAME = "SDKEventEmitter"
|
|
18
|
+
|
|
19
|
+
@JvmStatic
|
|
20
|
+
fun emit(eventName: String, event: Any?) {
|
|
21
|
+
instance?.reactApplicationContext?.getJSModule(
|
|
22
|
+
DeviceEventManagerModule.RCTDeviceEventEmitter::class.java
|
|
23
|
+
)?.emit(eventName, event)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
@JvmStatic
|
|
27
|
+
private var instance: SdkEventEmitter? = null
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
override fun getName(): String = NAME
|
|
31
|
+
|
|
32
|
+
init {
|
|
33
|
+
instance = this
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@ReactMethod
|
|
37
|
+
fun addListener(eventName: String) {
|
|
38
|
+
// No-op — required by NativeEventEmitter
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@ReactMethod
|
|
42
|
+
fun removeListeners(count: Double) {
|
|
43
|
+
// No-op — required by NativeEventEmitter
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
override fun onCatalystInstanceDestroy() {
|
|
47
|
+
super.onCatalystInstanceDestroy()
|
|
48
|
+
instance = null
|
|
49
|
+
}
|
|
50
|
+
}
|
|
@@ -7,9 +7,10 @@ package com.altcraft.sdk
|
|
|
7
7
|
import androidx.activity.ComponentActivity
|
|
8
8
|
import com.altcraft.sdk.config.AltcraftConfiguration
|
|
9
9
|
import com.altcraft.sdk.data.DataClasses
|
|
10
|
-
import com.altcraft.sdk.mob_events.
|
|
10
|
+
import com.altcraft.sdk.mob_events.PublicMobileEventFunctions
|
|
11
11
|
import com.altcraft.sdk.push.events.PublicPushEventFunctions
|
|
12
12
|
import com.altcraft.sdk.push.subscribe.PublicPushSubscriptionFunctions
|
|
13
|
+
import com.altcraft.sdk.profile.PublicProfileFunctions
|
|
13
14
|
import com.altcraft.sdk.push.token.PublicPushTokenFunctions
|
|
14
15
|
import com.altcraft.sdk.rn.getArrayOrNull
|
|
15
16
|
import com.altcraft.sdk.rn.getBooleanOrNull
|
|
@@ -31,7 +32,7 @@ import com.facebook.react.bridge.ReadableMap
|
|
|
31
32
|
import com.facebook.react.bridge.UiThreadUtil
|
|
32
33
|
import com.facebook.react.bridge.WritableMap
|
|
33
34
|
import com.facebook.react.module.annotations.ReactModule
|
|
34
|
-
|
|
35
|
+
|
|
35
36
|
import kotlinx.coroutines.CoroutineScope
|
|
36
37
|
import kotlinx.coroutines.Dispatchers
|
|
37
38
|
import kotlinx.coroutines.SupervisorJob
|
|
@@ -56,6 +57,10 @@ private object RnConstants {
|
|
|
56
57
|
const val ERR_GET_LATEST_STATUS: String = "getStatusOfLatestSubscription"
|
|
57
58
|
const val ERR_GET_CURRENT_STATUS: String = "getStatusForCurrentSubscription"
|
|
58
59
|
const val ERR_GET_LATEST_STATUS_PROVIDER: String = "getStatusOfLatestSubscriptionForProvider"
|
|
60
|
+
const val ERR_UPDATE_PROFILE_FIELDS: String = "updateProfileFields"
|
|
61
|
+
const val ERR_FORCED_TOKEN_UPDATE: String = "forcedTokenUpdate"
|
|
62
|
+
const val ERR_DELETE_DEVICE_TOKEN: String = "deleteDeviceToken"
|
|
63
|
+
const val ERR_CHANGE_PROVIDER_PRIORITY: String = "changePushProviderPriorityList"
|
|
59
64
|
|
|
60
65
|
// Promise reject messages
|
|
61
66
|
const val MSG_PROVIDER_IS_BLANK: String = "provider is blank"
|
|
@@ -272,7 +277,7 @@ class SdkModule(reactContext: ReactApplicationContext) : NativeSdkSpec(reactCont
|
|
|
272
277
|
)
|
|
273
278
|
}
|
|
274
279
|
|
|
275
|
-
|
|
280
|
+
PublicMobileEventFunctions.mobileEvent(
|
|
276
281
|
context = reactApplicationContext,
|
|
277
282
|
sid = sid,
|
|
278
283
|
eventName = eventName,
|
|
@@ -399,9 +404,7 @@ class SdkModule(reactContext: ReactApplicationContext) : NativeSdkSpec(reactCont
|
|
|
399
404
|
}
|
|
400
405
|
eventMap.putString(RnConstants.KEY_TYPE, type)
|
|
401
406
|
|
|
402
|
-
|
|
403
|
-
.getJSModule(RCTDeviceEventEmitter::class.java)
|
|
404
|
-
.emit(RnConstants.JS_EVENT_NAME, eventMap)
|
|
407
|
+
SdkEventEmitter.emit(RnConstants.JS_EVENT_NAME, eventMap)
|
|
405
408
|
}
|
|
406
409
|
|
|
407
410
|
// --------------------- subscription bridge ---------------------
|
|
@@ -582,6 +585,119 @@ class SdkModule(reactContext: ReactApplicationContext) : NativeSdkSpec(reactCont
|
|
|
582
585
|
}
|
|
583
586
|
}
|
|
584
587
|
|
|
588
|
+
// ---------------------- Profile API ----------------------
|
|
589
|
+
|
|
590
|
+
/**
|
|
591
|
+
* Updates profile fields on the server.
|
|
592
|
+
*
|
|
593
|
+
* @param profileFields Optional profile fields (string-only map).
|
|
594
|
+
* @param skipTriggers Optional flag to skip trigger execution on the server.
|
|
595
|
+
*/
|
|
596
|
+
override fun updateProfileFields(
|
|
597
|
+
profileFields: ReadableMap?,
|
|
598
|
+
skipTriggers: Boolean?
|
|
599
|
+
) {
|
|
600
|
+
try {
|
|
601
|
+
PublicProfileFunctions.updateProfileFields(
|
|
602
|
+
context = reactApplicationContext,
|
|
603
|
+
profileFields = Converter.toKotlinMap(profileFields),
|
|
604
|
+
skipTriggers = skipTriggers
|
|
605
|
+
)
|
|
606
|
+
} catch (e: Exception) {
|
|
607
|
+
e.printStackTrace()
|
|
608
|
+
}
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
// ---------------------- Token management API ----------------------
|
|
612
|
+
|
|
613
|
+
/**
|
|
614
|
+
* Forces a push token refresh (delete + re-register).
|
|
615
|
+
*
|
|
616
|
+
* @param promise Resolves when the token update flow completes.
|
|
617
|
+
*/
|
|
618
|
+
override fun forcedTokenUpdate(promise: Promise) {
|
|
619
|
+
coroutineScope.launch {
|
|
620
|
+
try {
|
|
621
|
+
PublicPushTokenFunctions.forcedTokenUpdate(reactApplicationContext) {
|
|
622
|
+
promise.resolve(null)
|
|
623
|
+
}
|
|
624
|
+
} catch (e: Exception) {
|
|
625
|
+
promise.reject(RnConstants.ERR_FORCED_TOKEN_UPDATE, e)
|
|
626
|
+
}
|
|
627
|
+
}
|
|
628
|
+
}
|
|
629
|
+
|
|
630
|
+
/**
|
|
631
|
+
* Deletes the device token for a given provider.
|
|
632
|
+
*
|
|
633
|
+
* @param provider Provider identifier (e.g. `android-firebase`).
|
|
634
|
+
* @param promise Resolves when the delete call is dispatched.
|
|
635
|
+
*/
|
|
636
|
+
override fun deleteDeviceToken(provider: String, promise: Promise) {
|
|
637
|
+
try {
|
|
638
|
+
PublicPushTokenFunctions.deleteDeviceToken(
|
|
639
|
+
context = reactApplicationContext,
|
|
640
|
+
provider = provider
|
|
641
|
+
) {
|
|
642
|
+
promise.resolve(null)
|
|
643
|
+
}
|
|
644
|
+
} catch (e: Exception) {
|
|
645
|
+
promise.reject(RnConstants.ERR_DELETE_DEVICE_TOKEN, e)
|
|
646
|
+
}
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
/**
|
|
650
|
+
* Changes the push provider priority list at runtime.
|
|
651
|
+
*
|
|
652
|
+
* @param priorityList Ordered list of provider identifiers.
|
|
653
|
+
* @param promise Resolves when the priority list is updated and token update is triggered.
|
|
654
|
+
*/
|
|
655
|
+
override fun changePushProviderPriorityList(priorityList: ReadableArray, promise: Promise) {
|
|
656
|
+
coroutineScope.launch {
|
|
657
|
+
try {
|
|
658
|
+
val list = priorityList.toStringList()
|
|
659
|
+
PublicPushTokenFunctions.changePushProviderPriorityList(
|
|
660
|
+
context = reactApplicationContext,
|
|
661
|
+
priorityList = list
|
|
662
|
+
)
|
|
663
|
+
promise.resolve(null)
|
|
664
|
+
} catch (e: Exception) {
|
|
665
|
+
promise.reject(RnConstants.ERR_CHANGE_PROVIDER_PRIORITY, e)
|
|
666
|
+
}
|
|
667
|
+
}
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
// ---------------------- PushReceiver helpers ----------------------
|
|
671
|
+
|
|
672
|
+
/**
|
|
673
|
+
* Checks whether a push payload belongs to Altcraft.
|
|
674
|
+
*
|
|
675
|
+
* @param message Push payload map (string-only).
|
|
676
|
+
* @return `true` if the message contains the Altcraft marker key.
|
|
677
|
+
*/
|
|
678
|
+
override fun isAltcraftPush(message: ReadableMap?): Boolean {
|
|
679
|
+
if (message == null) return false
|
|
680
|
+
val map = Converter.toStringMapOrNull(message) ?: return false
|
|
681
|
+
return AltcraftSDK.PushReceiver.isAltcraftPush(map)
|
|
682
|
+
}
|
|
683
|
+
|
|
684
|
+
// ---------------------- SDK lifecycle ----------------------
|
|
685
|
+
|
|
686
|
+
/**
|
|
687
|
+
* Allows re-running initial retry/scheduling/token-check logic
|
|
688
|
+
* in this process on the next [initialization].
|
|
689
|
+
*/
|
|
690
|
+
override fun unlockInitialOperationsInThisSession() {
|
|
691
|
+
AltcraftSDK.unlockInitialOperationsInThisSession()
|
|
692
|
+
}
|
|
693
|
+
|
|
694
|
+
/**
|
|
695
|
+
* Sets the App Group name (iOS-only, no-op on Android).
|
|
696
|
+
*/
|
|
697
|
+
override fun setAppGroup(groupName: String?) {
|
|
698
|
+
// no-op on Android
|
|
699
|
+
}
|
|
700
|
+
|
|
585
701
|
/**
|
|
586
702
|
* Maps {@link DataClasses.ResponseWithHttpCode} to a RN {@link WritableMap}. Returns `null` if
|
|
587
703
|
* input is `null`. Unmapped fields (`fields`, `cats`) are set to `null`.
|
|
@@ -810,10 +926,6 @@ internal object AltcraftRnConfigMapper {
|
|
|
810
926
|
|
|
811
927
|
val icon = config.getIntOrNull(KEY_ANDROID_ICON)
|
|
812
928
|
|
|
813
|
-
val usingService = config.getBooleanOrNull(KEY_ANDROID_USING_SERVICE) ?: false
|
|
814
|
-
|
|
815
|
-
val serviceMessage = config.getStringOrNull(KEY_ANDROID_SERVICE_MESSAGE)
|
|
816
|
-
|
|
817
929
|
val pushReceiverModules =
|
|
818
930
|
config.getArrayOrNull(KEY_ANDROID_PUSH_RECEIVER_MODULES)?.toStringList()
|
|
819
931
|
|
|
@@ -825,8 +937,6 @@ internal object AltcraftRnConfigMapper {
|
|
|
825
937
|
apiUrl = apiUrl,
|
|
826
938
|
icon = icon,
|
|
827
939
|
rToken = rToken,
|
|
828
|
-
usingService = usingService,
|
|
829
|
-
serviceMessage = serviceMessage,
|
|
830
940
|
appInfo = appInfo,
|
|
831
941
|
providerPriorityList = providerPriorityList,
|
|
832
942
|
pushReceiverModules = pushReceiverModules,
|
|
@@ -9,10 +9,10 @@ import java.util.HashMap
|
|
|
9
9
|
|
|
10
10
|
class SdkPackage : BaseReactPackage() {
|
|
11
11
|
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
|
|
12
|
-
return
|
|
13
|
-
SdkModule(reactContext)
|
|
14
|
-
|
|
15
|
-
null
|
|
12
|
+
return when (name) {
|
|
13
|
+
SdkModule.NAME -> SdkModule(reactContext)
|
|
14
|
+
SdkEventEmitter.NAME -> SdkEventEmitter(reactContext)
|
|
15
|
+
else -> null
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -22,10 +22,18 @@ class SdkPackage : BaseReactPackage() {
|
|
|
22
22
|
moduleInfos[SdkModule.NAME] = ReactModuleInfo(
|
|
23
23
|
SdkModule.NAME,
|
|
24
24
|
SdkModule.NAME,
|
|
25
|
-
false,
|
|
26
|
-
false,
|
|
27
|
-
false,
|
|
28
|
-
true
|
|
25
|
+
false,
|
|
26
|
+
false,
|
|
27
|
+
false,
|
|
28
|
+
true
|
|
29
|
+
)
|
|
30
|
+
moduleInfos[SdkEventEmitter.NAME] = ReactModuleInfo(
|
|
31
|
+
SdkEventEmitter.NAME,
|
|
32
|
+
SdkEventEmitter.NAME,
|
|
33
|
+
false,
|
|
34
|
+
false,
|
|
35
|
+
false,
|
|
36
|
+
false
|
|
29
37
|
)
|
|
30
38
|
moduleInfos
|
|
31
39
|
}
|
package/ios/Converter.swift
CHANGED
|
@@ -20,9 +20,9 @@ import Altcraft
|
|
|
20
20
|
/// - Conversion of arbitrary values into `UserDefaults`-compatible property list values.
|
|
21
21
|
///
|
|
22
22
|
/// All functions are stateless and intended to be used from the React Native bridge layer.
|
|
23
|
-
enum Converter {
|
|
23
|
+
enum Converter: @unchecked Sendable {
|
|
24
24
|
|
|
25
|
-
|
|
25
|
+
nonisolated(unsafe) static let iso8601: ISO8601DateFormatter = {
|
|
26
26
|
let f = ISO8601DateFormatter()
|
|
27
27
|
return f
|
|
28
28
|
}()
|
package/ios/Sdk.mm
CHANGED
|
@@ -837,6 +837,119 @@ static NSDictionary * _Nullable SdkConvertUTMToNSDictionary(JS::NativeSdk::UTM &
|
|
|
837
837
|
CallSetUserDefaultsValue(module, sn, k, v);
|
|
838
838
|
}
|
|
839
839
|
|
|
840
|
+
#pragma mark - Profile API
|
|
841
|
+
|
|
842
|
+
- (void)updateProfileFields:(NSDictionary * _Nullable)profileFields
|
|
843
|
+
skipTriggers:(NSNumber *)skipTriggers
|
|
844
|
+
{
|
|
845
|
+
id module = SdkAppModuleSharedInstance();
|
|
846
|
+
EnsureProvidersInstalled(module);
|
|
847
|
+
|
|
848
|
+
SEL sel = SdkSel(@"updateProfileFields:skipTriggers:");
|
|
849
|
+
if (!SdkResponds(module, sel)) return;
|
|
850
|
+
|
|
851
|
+
IMP imp = [module methodForSelector:sel];
|
|
852
|
+
if (!imp) return;
|
|
853
|
+
|
|
854
|
+
void (*func)(id, SEL, id, id) = (void (*)(id, SEL, id, id))imp;
|
|
855
|
+
func(module, sel, (NSDictionary *)SdkNilIfNSNull(profileFields), (NSNumber *)SdkNilIfNSNull(skipTriggers));
|
|
856
|
+
}
|
|
857
|
+
|
|
858
|
+
#pragma mark - Token management API
|
|
859
|
+
|
|
860
|
+
- (void)forcedTokenUpdate:(RCTPromiseResolveBlock)resolve
|
|
861
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
862
|
+
{
|
|
863
|
+
id module = SdkAppModuleSharedInstance();
|
|
864
|
+
EnsureProvidersInstalled(module);
|
|
865
|
+
CallPromise0Args(module, @"forcedTokenUpdateWithResolver:rejecter:", resolve, reject);
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
- (void)deleteDeviceToken:(NSString *)provider
|
|
869
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
870
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
871
|
+
{
|
|
872
|
+
id module = SdkAppModuleSharedInstance();
|
|
873
|
+
EnsureProvidersInstalled(module);
|
|
874
|
+
CallPromise1StringArg(module, @"deleteDeviceTokenWithProvider:resolver:rejecter:", provider, resolve, reject);
|
|
875
|
+
}
|
|
876
|
+
|
|
877
|
+
- (void)changePushProviderPriorityList:(NSArray *)priorityList
|
|
878
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
879
|
+
reject:(RCTPromiseRejectBlock)reject
|
|
880
|
+
{
|
|
881
|
+
id module = SdkAppModuleSharedInstance();
|
|
882
|
+
EnsureProvidersInstalled(module);
|
|
883
|
+
|
|
884
|
+
SEL sel = SdkSel(@"changePushProviderPriorityList:");
|
|
885
|
+
if (!SdkResponds(module, sel)) {
|
|
886
|
+
reject(@"ERR_METHOD_NOT_FOUND", @"changePushProviderPriorityList: not found", nil);
|
|
887
|
+
return;
|
|
888
|
+
}
|
|
889
|
+
|
|
890
|
+
IMP imp = [module methodForSelector:sel];
|
|
891
|
+
if (!imp) {
|
|
892
|
+
reject(@"ERR_METHOD_NOT_FOUND", @"changePushProviderPriorityList: not found", nil);
|
|
893
|
+
return;
|
|
894
|
+
}
|
|
895
|
+
|
|
896
|
+
void (*func)(id, SEL, id) = (void (*)(id, SEL, id))imp;
|
|
897
|
+
func(module, sel, priorityList ?: @[]);
|
|
898
|
+
resolve((id)kCFNull);
|
|
899
|
+
}
|
|
900
|
+
|
|
901
|
+
#pragma mark - PushReceiver helpers
|
|
902
|
+
|
|
903
|
+
- (NSNumber *)isAltcraftPush:(NSDictionary * _Nullable)message
|
|
904
|
+
{
|
|
905
|
+
id module = SdkAppModuleSharedInstance();
|
|
906
|
+
if (!module) return @NO;
|
|
907
|
+
|
|
908
|
+
SEL sel = SdkSel(@"isAltcraftPush:");
|
|
909
|
+
if (!SdkResponds(module, sel)) return @NO;
|
|
910
|
+
|
|
911
|
+
IMP imp = [module methodForSelector:sel];
|
|
912
|
+
if (!imp) return @NO;
|
|
913
|
+
|
|
914
|
+
BOOL (*func)(id, SEL, id) = (BOOL (*)(id, SEL, id))imp;
|
|
915
|
+
BOOL result = func(module, sel, (NSDictionary *)SdkNilIfNSNull(message));
|
|
916
|
+
return [NSNumber numberWithBool:result];
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
#pragma mark - Session unlock
|
|
920
|
+
|
|
921
|
+
- (void)unlockInitialOperationsInThisSession
|
|
922
|
+
{
|
|
923
|
+
id module = SdkAppModuleSharedInstance();
|
|
924
|
+
if (!module) return;
|
|
925
|
+
|
|
926
|
+
SEL sel = SdkSel(@"unlockInitialOperationsInThisSession");
|
|
927
|
+
if (!SdkResponds(module, sel)) return;
|
|
928
|
+
|
|
929
|
+
IMP imp = [module methodForSelector:sel];
|
|
930
|
+
if (!imp) return;
|
|
931
|
+
|
|
932
|
+
void (*func)(id, SEL) = (void (*)(id, SEL))imp;
|
|
933
|
+
func(module, sel);
|
|
934
|
+
}
|
|
935
|
+
|
|
936
|
+
#pragma mark - App Group
|
|
937
|
+
|
|
938
|
+
- (void)setAppGroup:(NSString * _Nullable)groupName
|
|
939
|
+
{
|
|
940
|
+
id module = SdkAppModuleSharedInstance();
|
|
941
|
+
if (!module) return;
|
|
942
|
+
|
|
943
|
+
SEL sel = SdkSel(@"setAppGroup:");
|
|
944
|
+
if (!SdkResponds(module, sel)) return;
|
|
945
|
+
|
|
946
|
+
IMP imp = [module methodForSelector:sel];
|
|
947
|
+
if (!imp) return;
|
|
948
|
+
|
|
949
|
+
void (*func)(id, SEL, id) = (void (*)(id, SEL, id))imp;
|
|
950
|
+
func(module, sel, (NSString *)SdkNilIfNSNull(groupName));
|
|
951
|
+
}
|
|
952
|
+
|
|
840
953
|
#pragma mark - iOS-only stubs (kept if present in spec / facade)
|
|
841
954
|
|
|
842
955
|
- (void)deliveryEvent:(NSDictionary * _Nullable)message
|