@altcraft/react-native-sdk 0.0.2 → 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.
Files changed (36) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +119 -27
  3. package/Sdk.podspec +2 -2
  4. package/android/build.gradle +3 -4
  5. package/android/src/main/java/com/altcraft/sdk/SdkEventEmitter.kt +50 -0
  6. package/android/src/main/java/com/altcraft/sdk/SdkModule.kt +663 -480
  7. package/android/src/main/java/com/altcraft/sdk/SdkPackage.kt +16 -8
  8. package/android/src/main/java/com/altcraft/sdk/utilities/Converter.kt +164 -0
  9. package/android/src/main/java/com/altcraft/sdk/utilities/Extension.kt +72 -0
  10. package/ios/Converter.swift +485 -48
  11. package/ios/Sdk.mm +195 -270
  12. package/ios/SdkModule.swift +456 -507
  13. package/lib/module/NativeSdk.js +35 -0
  14. package/lib/module/NativeSdk.js.map +1 -1
  15. package/lib/module/Utilities.js +178 -0
  16. package/lib/module/Utilities.js.map +1 -0
  17. package/lib/module/index.js +335 -245
  18. package/lib/module/index.js.map +1 -1
  19. package/lib/typescript/src/NativeSdk.d.ts +125 -33
  20. package/lib/typescript/src/NativeSdk.d.ts.map +1 -1
  21. package/lib/typescript/src/Utilities.d.ts +47 -0
  22. package/lib/typescript/src/Utilities.d.ts.map +1 -0
  23. package/lib/typescript/src/index.d.ts +218 -94
  24. package/lib/typescript/src/index.d.ts.map +1 -1
  25. package/package.json +1 -1
  26. package/src/NativeSdk.ts +169 -46
  27. package/src/Utilities.ts +180 -0
  28. package/src/index.tsx +410 -312
  29. package/android/src/main/java/com/altcraft/sdk/interfaces/RnFCMProvider.kt +0 -26
  30. package/android/src/main/java/com/altcraft/sdk/interfaces/RnHMSProvider.kt +0 -32
  31. package/android/src/main/java/com/altcraft/sdk/interfaces/RnJWTProvider.kt +0 -21
  32. package/android/src/main/java/com/altcraft/sdk/interfaces/RnRustoreProvider.kt +0 -53
  33. package/ios/protocols/RNAPNSProvider.swift +0 -15
  34. package/ios/protocols/RNFCMProvider.swift +0 -24
  35. package/ios/protocols/RNHMSProvider.swift +0 -24
  36. package/ios/protocols/RNJWTProvider.swift +0 -15
package/LICENSE CHANGED
@@ -1,20 +1,20 @@
1
- # END-USER LICENSE AGREEMENT
2
-
3
- Copyright © 2024 Altcraft LLC. All rights reserved.
4
-
5
- 1. **GRANT OF LICENSE**: This document grants you certain rights to use the Altcraft Mobile SDK (hereinafter referred to as the "Software"). All rights not expressly granted are reserved by the copyright holder.
6
-
7
- 2. **USE**: You have the right to use and distribute the Software for both commercial and non-commercial purposes.
8
-
9
- 3. **MODIFICATION WITHOUT PUBLICATION**: You may modify the Software for your own use without the obligation to publish these modifications.
10
-
11
- 4. **MODIFICATION WITH PUBLICATION**: Any publication of modified Software requires prior written permission from the copyright holder.
12
-
13
- 5. **DISCLAIMER OF WARRANTY**: The Software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement.
14
-
15
- 6. **LIMITATION OF LIABILITY**: In no event shall the copyright holder be liable for any direct, indirect, incidental, special, exemplary, or consequential damages (including, but not limited to, procurement of substitute goods or services; loss of use, data, or profits; or business interruption) however caused and on any theory of liability, whether in contract, strict liability, or tort (including negligence or otherwise) arising in any way out of the use of this Software, even if advised of the possibility of such damage.
16
-
17
- 7. **DISTRIBUTION**: When distributing the Software, you must provide all recipients with a copy of this license agreement.
18
-
19
- 8. **COPYRIGHT NOTICE AND THIRD-PARTY COMPONENTS**:
20
- This Software may include components released under other licenses. A complete list of these components and their respective licenses is provided below:
1
+ MIT License
2
+
3
+ Copyright (c) 2025 Altcraft
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in all
12
+ copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
20
+ SOFTWARE.
package/README.md CHANGED
@@ -2,45 +2,137 @@
2
2
 
3
3
  ![Altcraft SDK Logo](https://guides.altcraft.com/img/logo.svg)
4
4
 
5
- [![npm version](https://img.shields.io/npm/v/altcraft-react-native-sdk?style=flat-square)](https://www.npmjs.com/package/altcraft-react-native-sdk)
6
- [![npm downloads](https://img.shields.io/npm/dm/altcraft-react-native-sdk?style=flat-square)](https://www.npmjs.com/package/altcraft-react-native-sdk)
7
- [![React Native](https://img.shields.io/badge/React%20Native-0.70%2B-blue?style=flat-square)](#)
8
- [![Platforms](https://img.shields.io/badge/Platform-Android-green?style=flat-square)](#)
9
- [![Push](https://img.shields.io/badge/Push-Firebase%20FCM%20%7C%20Huawei%20HMS%20%7C%20RuStore-green?style=flat-square)](#)
5
+ [![npm version](https://img.shields.io/npm/v/react-native-sdk?style=flat-square)](https://www.npmjs.com/package/react-native-sdk)
6
+ [![React Native](https://img.shields.io/badge/React_Native-0.70%2B-blue?style=flat-square)](https://reactnative.dev/)
7
+ [![Platforms](https://img.shields.io/badge/Platforms-Android_%7C_iOS-green?style=flat-square)](#)
8
+ [![Push Providers](https://img.shields.io/badge/Push-FCM_%7C_APNs-orange?style=flat-square)](#)
10
9
 
11
- Altcraft React Native SDK. It helps manage push subscriptions, tokens, SDK events, and sending mobile events to the Altcraft platform.
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.
12
11
 
13
12
  ---
14
13
 
15
14
  ## Features
16
15
 
17
- - Push subscription management:
18
- - `pushSubscribe`
19
- - `pushSuspend`
20
- - `pushUnSubscribe`
21
- - `getStatus...` APIs
22
- - Push token management:
23
- - get current token (`getPushToken`)
24
- - set/delete token, force update, provider priority list
25
- - JWT support (`setJwt`)
26
- - Mobile events (`mobileEvent`)
27
- - SDK event stream from native to JS (`subscribeToEvents`)
28
- - Push intake forwarding (`takePush`) to native SDK
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.
29
61
 
30
62
  ---
31
63
 
32
64
  ## Requirements
33
65
 
34
- - React Native: depends on your RN version and New Architecture setup (TurboModules).
35
- - Android:
36
- - `minSdk` and `compileSdk` depend on your app configuration
37
- - Push provider integrated in the host app (FCM / APNS/ HMS / RuStore)
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).
38
70
 
39
71
  ---
40
72
 
41
- ## Installation
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/)
86
+
87
+ ---
88
+
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**
42
137
 
43
- ```sh
44
- yarn add altcraft-react-native-sdk
45
- # or
46
- 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 = "5.0"
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.1.2"
33
+ s.dependency "Altcraft", "1.0.3"
34
34
 
35
35
  # --- React Native module deps ---
36
36
  install_modules_dependencies(s)
@@ -10,12 +10,10 @@ buildscript {
10
10
 
11
11
  dependencies {
12
12
  classpath "com.android.tools.build:gradle:8.7.2"
13
- // noinspection DifferentKotlinGradleVersion
14
13
  classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:${getExtOrDefault('kotlinVersion')}"
15
14
  }
16
15
  }
17
16
 
18
-
19
17
  apply plugin: "com.android.library"
20
18
  apply plugin: "kotlin-android"
21
19
 
@@ -72,7 +70,8 @@ repositories {
72
70
  def kotlin_version = getExtOrDefault("kotlinVersion")
73
71
 
74
72
  dependencies {
73
+ api "com.altcraft:android-sdk:1.0.6"
75
74
  implementation "com.facebook.react:react-android"
76
75
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
77
- implementation "com.altcraft:android-sdk:0.0.4"
78
- }
76
+ implementation "org.jetbrains.kotlinx:kotlinx-serialization-json:1.6.3"
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
+ }