@altcraft/react-native-sdk 0.0.3 → 0.0.5
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/LICENSE +48 -20
- 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 +55 -0
- package/android/src/main/java/com/altcraft/sdk/SdkModule.kt +889 -735
- 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 +4 -4
- package/src/NativeSdk.ts +34 -2
- package/src/Utilities.ts +66 -2
- package/src/index.tsx +169 -41
package/LICENSE
CHANGED
|
@@ -1,20 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
1
|
+
EULA
|
|
2
|
+
|
|
3
|
+
END USER LICENSE AGREEMENT
|
|
4
|
+
|
|
5
|
+
Copyright © 2026 Altcraft LLC. All rights reserved.
|
|
6
|
+
|
|
7
|
+
1. LICENSE GRANT
|
|
8
|
+
This agreement grants you certain rights to use the Altcraft Mobile SDK (hereinafter referred to as the "Software").
|
|
9
|
+
All rights not expressly granted by this agreement remain with the copyright holder.
|
|
10
|
+
|
|
11
|
+
2. USE
|
|
12
|
+
You are permitted to use and distribute the Software for both commercial and non-commercial purposes.
|
|
13
|
+
|
|
14
|
+
3. MODIFICATION WITHOUT PUBLICATION
|
|
15
|
+
You may modify the Software for your own internal purposes without any obligation to publish such modifications.
|
|
16
|
+
|
|
17
|
+
4. MODIFICATION WITH PUBLICATION
|
|
18
|
+
Publication of modified Software requires prior written permission from the copyright holder.
|
|
19
|
+
|
|
20
|
+
5. DISCLAIMER OF WARRANTIES
|
|
21
|
+
The Software is provided "as is," without any warranties, express or implied, including but not limited to
|
|
22
|
+
warranties of merchantability, fitness for a particular purpose, and non-infringement of third-party rights.
|
|
23
|
+
|
|
24
|
+
6. LIMITATION OF LIABILITY
|
|
25
|
+
Under no circumstances shall the copyright holder be liable for any direct, indirect, incidental, special,
|
|
26
|
+
punitive, or consequential damages (including but not limited to: procurement of substitute goods or services;
|
|
27
|
+
loss of data, profits, or business interruption) arising in any way from the use of this Software,
|
|
28
|
+
even if the copyright holder has been advised of the possibility of such damages.
|
|
29
|
+
|
|
30
|
+
7. DISTRIBUTION
|
|
31
|
+
When distributing the Software, you must provide all recipients with a copy of this license agreement.
|
|
32
|
+
|
|
33
|
+
8. COPYRIGHT AND THIRD-PARTY COMPONENTS
|
|
34
|
+
This Software may include components distributed under other licenses. The full list of such components
|
|
35
|
+
and their respective licenses is provided below:
|
|
36
|
+
|
|
37
|
+
### Third-party libraries and licenses
|
|
38
|
+
|
|
39
|
+
**Apache License 2.0**
|
|
40
|
+
Licensed under the [Apache License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0).
|
|
41
|
+
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
|
|
42
|
+
|
|
43
|
+
* [React Native](https://github.com/facebook/react-native)
|
|
44
|
+
* [TypeScript](https://www.typescriptlang.org/)
|
|
45
|
+
|
|
46
|
+
**MIT License**
|
|
47
|
+
|
|
48
|
+
* [React](https://github.com/facebook/react)
|
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:0.0.5`
|
|
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,55 @@
|
|
|
1
|
+
package com.altcraft.sdk
|
|
2
|
+
|
|
3
|
+
import android.util.Log
|
|
4
|
+
import com.facebook.react.bridge.ReactApplicationContext
|
|
5
|
+
import com.facebook.react.bridge.ReactContextBaseJavaModule
|
|
6
|
+
import com.facebook.react.bridge.ReactMethod
|
|
7
|
+
import com.facebook.react.module.annotations.ReactModule
|
|
8
|
+
import com.facebook.react.modules.core.DeviceEventManagerModule
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Event emitter module for NativeEventEmitter on the JS side.
|
|
12
|
+
* SdkModule calls [emit] to forward SDK events to JS.
|
|
13
|
+
*/
|
|
14
|
+
@ReactModule(name = SdkEventEmitter.NAME)
|
|
15
|
+
class SdkEventEmitter(reactContext: ReactApplicationContext) : ReactContextBaseJavaModule(reactContext) {
|
|
16
|
+
|
|
17
|
+
companion object {
|
|
18
|
+
const val NAME = "SDKEventEmitter"
|
|
19
|
+
|
|
20
|
+
@JvmStatic
|
|
21
|
+
fun emit(eventName: String, event: Any?) {
|
|
22
|
+
try {
|
|
23
|
+
instance?.reactApplicationContext?.getJSModule(
|
|
24
|
+
DeviceEventManagerModule.RCTDeviceEventEmitter::class.java
|
|
25
|
+
)?.emit(eventName, event)
|
|
26
|
+
} catch (e: Exception) {
|
|
27
|
+
Log.e("altcraft_lib_android_bridge", "SdkEventEmitter.emit failed: ${e.message}")
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
@JvmStatic
|
|
32
|
+
private var instance: SdkEventEmitter? = null
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
override fun getName(): String = NAME
|
|
36
|
+
|
|
37
|
+
init {
|
|
38
|
+
instance = this
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@ReactMethod
|
|
42
|
+
fun addListener(eventName: String) {
|
|
43
|
+
// No-op — required by NativeEventEmitter
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@ReactMethod
|
|
47
|
+
fun removeListeners(count: Double) {
|
|
48
|
+
// No-op — required by NativeEventEmitter
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
override fun onCatalystInstanceDestroy() {
|
|
52
|
+
super.onCatalystInstanceDestroy()
|
|
53
|
+
instance = null
|
|
54
|
+
}
|
|
55
|
+
}
|