@altcraft/react-native-sdk 0.0.2 → 0.0.3
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 +20 -20
- package/README.md +5 -2
- package/android/build.gradle +2 -3
- package/android/src/main/java/com/altcraft/sdk/SdkModule.kt +551 -478
- package/android/src/main/java/com/altcraft/sdk/utilities/Converter.kt +164 -0
- package/android/src/main/java/com/altcraft/sdk/utilities/Extension.kt +72 -0
- package/ios/Converter.swift +483 -46
- package/ios/Sdk.mm +83 -271
- package/ios/SdkModule.swift +335 -493
- package/lib/module/NativeSdk.js +35 -0
- package/lib/module/NativeSdk.js.map +1 -1
- package/lib/module/Utilities.js +94 -0
- package/lib/module/Utilities.js.map +1 -0
- package/lib/module/index.js +224 -246
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/src/NativeSdk.d.ts +107 -31
- package/lib/typescript/src/NativeSdk.d.ts.map +1 -1
- package/lib/typescript/src/Utilities.d.ts +15 -0
- package/lib/typescript/src/Utilities.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +162 -94
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/NativeSdk.ts +135 -44
- package/src/Utilities.ts +116 -0
- package/src/index.tsx +281 -311
- package/android/src/main/java/com/altcraft/sdk/interfaces/RnFCMProvider.kt +0 -26
- package/android/src/main/java/com/altcraft/sdk/interfaces/RnHMSProvider.kt +0 -32
- package/android/src/main/java/com/altcraft/sdk/interfaces/RnJWTProvider.kt +0 -21
- package/android/src/main/java/com/altcraft/sdk/interfaces/RnRustoreProvider.kt +0 -53
- package/ios/protocols/RNAPNSProvider.swift +0 -15
- package/ios/protocols/RNFCMProvider.swift +0 -24
- package/ios/protocols/RNHMSProvider.swift +0 -24
- package/ios/protocols/RNJWTProvider.swift +0 -15
package/lib/module/index.js
CHANGED
|
@@ -2,125 +2,188 @@
|
|
|
2
2
|
|
|
3
3
|
import { NativeEventEmitter, NativeModules } from 'react-native';
|
|
4
4
|
import NativeSDK from "./NativeSdk.js";
|
|
5
|
+
import { Utilities } from "./Utilities.js";
|
|
5
6
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
switch (typeof value) {
|
|
19
|
-
case 'string':
|
|
20
|
-
out[key] = value;
|
|
21
|
-
break;
|
|
22
|
-
case 'number':
|
|
23
|
-
case 'boolean':
|
|
24
|
-
case 'bigint':
|
|
25
|
-
out[key] = String(value);
|
|
26
|
-
break;
|
|
27
|
-
default:
|
|
28
|
-
try {
|
|
29
|
-
out[key] = JSON.stringify(value);
|
|
30
|
-
} catch {
|
|
31
|
-
out[key] = String(value);
|
|
32
|
-
}
|
|
33
|
-
break;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return Object.keys(out).length > 0 ? out : null;
|
|
7
|
+
// ---------------- SDK API ----------------
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Initializes the Altcraft SDK.
|
|
11
|
+
*
|
|
12
|
+
* @param config SDK configuration.
|
|
13
|
+
* `apiUrl` is required.
|
|
14
|
+
* Other fields are optional and depend on platform features.
|
|
15
|
+
* @returns Promise that resolves on successful initialization.
|
|
16
|
+
*/
|
|
17
|
+
export function initialize(config) {
|
|
18
|
+
return NativeSDK.initialize(config);
|
|
37
19
|
}
|
|
38
20
|
|
|
21
|
+
// ---------------- Push subscription ----------------
|
|
22
|
+
|
|
39
23
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
24
|
+
* Sends a push subscribe request.
|
|
25
|
+
*
|
|
26
|
+
* @param sync Execution mode:
|
|
27
|
+
* `true` — sends a synchronous request to the server and returns
|
|
28
|
+
* the result of the operation execution.
|
|
29
|
+
* `false` — sends an asynchronous request and returns
|
|
30
|
+
* the result of task enqueueing on the server.
|
|
31
|
+
* `null` — native default behavior.
|
|
32
|
+
* @param profileFields Optional profile fields to attach to the request.
|
|
33
|
+
* @param customFields Optional custom fields to attach to the request.
|
|
34
|
+
* @param cats Optional categories list.
|
|
35
|
+
* @param replace Optional flag to replace an existing subscription.
|
|
36
|
+
* @param skipTriggers Optional flag to skip trigger execution on the server.
|
|
47
37
|
*/
|
|
48
|
-
function
|
|
49
|
-
|
|
50
|
-
const t = typeof value;
|
|
51
|
-
if (t === 'string') return String(value);
|
|
52
|
-
if (t === 'number' || t === 'boolean') return String(value);
|
|
53
|
-
try {
|
|
54
|
-
return JSON.stringify(value);
|
|
55
|
-
} catch {
|
|
56
|
-
return String(value);
|
|
57
|
-
}
|
|
38
|
+
export function pushSubscribe(sync = true, profileFields = null, customFields = null, cats = null, replace = null, skipTriggers = null) {
|
|
39
|
+
NativeSDK.pushSubscribe(sync, Utilities.toNativeStringMap(profileFields), Utilities.toNativeStringMap(customFields), cats, replace, skipTriggers);
|
|
58
40
|
}
|
|
59
41
|
|
|
60
|
-
|
|
42
|
+
/**
|
|
43
|
+
* Sends a push suspend request.
|
|
44
|
+
*
|
|
45
|
+
* @param sync Execution mode (see {@link pushSubscribe}).
|
|
46
|
+
* @param profileFields Optional profile fields.
|
|
47
|
+
* @param customFields Optional custom fields.
|
|
48
|
+
* @param cats Optional categories list.
|
|
49
|
+
* @param replace Optional flag to replace an existing subscription.
|
|
50
|
+
* @param skipTriggers Optional flag to skip trigger execution on the server.
|
|
51
|
+
*/
|
|
52
|
+
export function pushSuspend(sync = true, profileFields = null, customFields = null, cats = null, replace = null, skipTriggers = null) {
|
|
53
|
+
NativeSDK.pushSuspend(sync, Utilities.toNativeStringMap(profileFields), Utilities.toNativeStringMap(customFields), cats, replace, skipTriggers);
|
|
54
|
+
}
|
|
61
55
|
|
|
62
|
-
/**
|
|
63
|
-
|
|
56
|
+
/**
|
|
57
|
+
* Sends a push unsubscribe request.
|
|
58
|
+
*
|
|
59
|
+
* @param sync Execution mode (see {@link pushSubscribe}).
|
|
60
|
+
* @param profileFields Optional profile fields.
|
|
61
|
+
* @param customFields Optional custom fields.
|
|
62
|
+
* @param cats Optional categories list.
|
|
63
|
+
* @param replace Optional flag to replace an existing subscription.
|
|
64
|
+
* @param skipTriggers Optional flag to skip trigger execution on the server.
|
|
65
|
+
*/
|
|
66
|
+
export function pushUnSubscribe(sync = true, profileFields = null, customFields = null, cats = null, replace = null, skipTriggers = null) {
|
|
67
|
+
NativeSDK.pushUnSubscribe(sync, Utilities.toNativeStringMap(profileFields), Utilities.toNativeStringMap(customFields), cats, replace, skipTriggers);
|
|
68
|
+
}
|
|
64
69
|
|
|
65
|
-
|
|
66
|
-
const registeredPushReceivers = [];
|
|
70
|
+
// ---------------- Promise APIs ----------------
|
|
67
71
|
|
|
68
|
-
/**
|
|
69
|
-
|
|
70
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Unsuspends push subscriptions based on native matching rules.
|
|
74
|
+
*
|
|
75
|
+
* @returns Promise resolving to response with HTTP code or `null` if unavailable.
|
|
76
|
+
*/
|
|
77
|
+
export function unSuspendPushSubscription() {
|
|
78
|
+
return NativeSDK.unSuspendPushSubscription();
|
|
71
79
|
}
|
|
72
80
|
|
|
73
|
-
/**
|
|
74
|
-
|
|
75
|
-
|
|
81
|
+
/**
|
|
82
|
+
* Returns the status of the latest subscription in profile.
|
|
83
|
+
*
|
|
84
|
+
* @returns Promise resolving to response with HTTP code or `null` if unavailable.
|
|
85
|
+
*/
|
|
86
|
+
export function getStatusOfLatestSubscription() {
|
|
87
|
+
return NativeSDK.getStatusOfLatestSubscription();
|
|
76
88
|
}
|
|
77
89
|
|
|
78
|
-
/**
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
90
|
+
/**
|
|
91
|
+
* Returns the status of the subscription matching the current push token and provider context.
|
|
92
|
+
*
|
|
93
|
+
* @returns Promise resolving to response with HTTP code or `null` if unavailable.
|
|
94
|
+
*/
|
|
95
|
+
export function getStatusForCurrentSubscription() {
|
|
96
|
+
return NativeSDK.getStatusForCurrentSubscription();
|
|
84
97
|
}
|
|
85
98
|
|
|
86
99
|
/**
|
|
87
|
-
*
|
|
88
|
-
*
|
|
100
|
+
* Returns the status of the latest subscription for the given provider.
|
|
101
|
+
*
|
|
102
|
+
* If `provider` is `null`, native side may use the current provider context.
|
|
103
|
+
*
|
|
104
|
+
* @param provider Optional provider identifier (platform-dependent).
|
|
105
|
+
* @returns Promise resolving to response with HTTP code or `null` if unavailable.
|
|
89
106
|
*/
|
|
90
|
-
export function
|
|
91
|
-
|
|
92
|
-
NativeSDK.takePush({
|
|
93
|
-
...message
|
|
94
|
-
});
|
|
95
|
-
const receivers = registeredPushReceivers.length > 0 ? registeredPushReceivers : [new DefaultPushReceiver()];
|
|
96
|
-
for (const receiver of receivers) {
|
|
97
|
-
try {
|
|
98
|
-
receiver.pushHandler(message);
|
|
99
|
-
} catch (e) {
|
|
100
|
-
// eslint-disable-next-line no-console
|
|
101
|
-
console.warn('[AltcraftSDK] PushReceiver error:', e);
|
|
102
|
-
}
|
|
103
|
-
}
|
|
107
|
+
export function getStatusOfLatestSubscriptionForProvider(provider = null) {
|
|
108
|
+
return NativeSDK.getStatusOfLatestSubscriptionForProvider(provider);
|
|
104
109
|
}
|
|
105
110
|
|
|
106
|
-
// ----------------
|
|
111
|
+
// ---------------- Token API ----------------
|
|
107
112
|
|
|
108
|
-
/**
|
|
113
|
+
/**
|
|
114
|
+
* Returns the current push token data from native side.
|
|
115
|
+
*
|
|
116
|
+
* @returns Promise resolving to token info or `null` if token is not available.
|
|
117
|
+
*/
|
|
118
|
+
export function getPushToken() {
|
|
119
|
+
return NativeSDK.getPushToken();
|
|
120
|
+
}
|
|
109
121
|
|
|
110
|
-
/**
|
|
111
|
-
|
|
122
|
+
/**
|
|
123
|
+
* Sets or clears the push token for a specific provider.
|
|
124
|
+
*
|
|
125
|
+
* @param provider Provider identifier (e.g. platform push provider name).
|
|
126
|
+
* @param token Token string or `null` to clear.
|
|
127
|
+
* @returns Promise that resolves when the token is saved on native side.
|
|
128
|
+
*/
|
|
129
|
+
export function setPushToken(provider, token) {
|
|
130
|
+
return NativeSDK.setPushToken(provider, token);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
// ---------------- SDK wrappers ----------------
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Clears SDK local state (native).
|
|
137
|
+
*
|
|
138
|
+
* @returns Promise that resolves after cleanup.
|
|
139
|
+
*/
|
|
140
|
+
export function clear() {
|
|
141
|
+
return NativeSDK.clear();
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
// ---------------- MobileEvent ----------------
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Sends a mobile event to the server.
|
|
148
|
+
*
|
|
149
|
+
* @param sid Pixel identifier.
|
|
150
|
+
* @param eventName Event name.
|
|
151
|
+
* @param sendMessageId Optional message identifier to link the event.
|
|
152
|
+
* @param payload Optional event payload.
|
|
153
|
+
* @param matching Optional matching parameters.
|
|
154
|
+
* @param matchingType Optional matching mode/type.
|
|
155
|
+
* @param profileFields Optional profile fields.
|
|
156
|
+
* @param subscription Optional subscription info to attach (email/sms/push/cc_data).
|
|
157
|
+
* @param utm Optional UTM tags for attribution.
|
|
158
|
+
*/
|
|
159
|
+
export function mobileEvent(sid, eventName, sendMessageId = null, payload = null, matching = null, matchingType = null, profileFields = null, subscription = null, utm = null) {
|
|
160
|
+
NativeSDK.mobileEvent(sid, eventName, sendMessageId, Utilities.toNativeStringMap(payload), Utilities.toNativeStringMap(matching), matchingType, Utilities.toNativeStringMap(profileFields), Utilities.subscriptionToNativeMap(subscription), utm);
|
|
161
|
+
}
|
|
112
162
|
|
|
113
|
-
|
|
163
|
+
// ---------------- SDK Event API ----------------
|
|
164
|
+
|
|
165
|
+
const ALTCRAFT_SDK_EVENT_NAME = 'AltcraftSdkEvent';
|
|
166
|
+
const nativeEventEmitter = new NativeEventEmitter(NativeModules.SDKEventEmitter);
|
|
114
167
|
let eventsSubscription = null;
|
|
115
168
|
|
|
116
|
-
/**
|
|
169
|
+
/**
|
|
170
|
+
* Subscribes to native SDK events and routes them to the provided handler.
|
|
171
|
+
*
|
|
172
|
+
* The SDK emits events via `NativeEventEmitter` with name {@link ALTCRAFT_SDK_EVENT_NAME}.
|
|
173
|
+
* Calling this function multiple times replaces the previous JS listener.
|
|
174
|
+
*
|
|
175
|
+
* @param handler Callback invoked for each incoming SDK event.
|
|
176
|
+
* The event object is produced by native and follows {@link SdkEvent}.
|
|
177
|
+
*/
|
|
117
178
|
export function subscribeToEvents(handler) {
|
|
118
179
|
if (eventsSubscription) {
|
|
119
180
|
eventsSubscription.remove();
|
|
120
181
|
eventsSubscription = null;
|
|
121
182
|
}
|
|
183
|
+
|
|
184
|
+
// Enables native-side subscription (starts producing events).
|
|
122
185
|
NativeSDK.subscribeToEvents();
|
|
123
|
-
eventsSubscription = nativeEventEmitter.addListener(
|
|
186
|
+
eventsSubscription = nativeEventEmitter.addListener(ALTCRAFT_SDK_EVENT_NAME, (...args) => {
|
|
124
187
|
const event = args[0] ?? null;
|
|
125
188
|
if (!event) return;
|
|
126
189
|
try {
|
|
@@ -131,7 +194,12 @@ export function subscribeToEvents(handler) {
|
|
|
131
194
|
});
|
|
132
195
|
}
|
|
133
196
|
|
|
134
|
-
/**
|
|
197
|
+
/**
|
|
198
|
+
* Unsubscribes from native SDK events.
|
|
199
|
+
*
|
|
200
|
+
* Removes the JS listener and instructs native module to stop emitting events.
|
|
201
|
+
* Safe to call even if not subscribed.
|
|
202
|
+
*/
|
|
135
203
|
export function unsubscribeFromEvent() {
|
|
136
204
|
if (eventsSubscription) {
|
|
137
205
|
eventsSubscription.remove();
|
|
@@ -140,204 +208,114 @@ export function unsubscribeFromEvent() {
|
|
|
140
208
|
NativeSDK.unsubscribeFromEvent();
|
|
141
209
|
}
|
|
142
210
|
|
|
143
|
-
//
|
|
144
|
-
|
|
145
|
-
/** Initializes the Altcraft SDK. */
|
|
146
|
-
export function initialize(config) {
|
|
147
|
-
return NativeSDK.initialize(config);
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/** Sets or clears the JWT used by the SDK. */
|
|
151
|
-
export function setJwt(token) {
|
|
152
|
-
return NativeSDK.setJwt(token);
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
// platform-specific token setters
|
|
156
|
-
|
|
157
|
-
/** Android-only: sets FCM token. */
|
|
158
|
-
export function setAndroidFcmToken(token) {
|
|
159
|
-
return NativeSDK.setAndroidFcmToken(token);
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
/** iOS-only: sets FCM token. */
|
|
163
|
-
export function setIosFcmToken(token) {
|
|
164
|
-
return NativeSDK.setIosFcmToken(token);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/** Android-only: sets HMS token. */
|
|
168
|
-
export function setAndroidHmsToken(token) {
|
|
169
|
-
return NativeSDK.setAndroidHmsToken(token);
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
/** iOS-only: sets HMS token. */
|
|
173
|
-
export function setIosHmsToken(token) {
|
|
174
|
-
return NativeSDK.setIosHmsToken(token);
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
/** iOS-only: sets APNs token. */
|
|
178
|
-
export function setApnsToken(token) {
|
|
179
|
-
return NativeSDK.setApnsToken(token);
|
|
180
|
-
}
|
|
181
|
-
|
|
182
|
-
/** Android-only: sets RuStore token. */
|
|
183
|
-
export function setRustoreToken(token) {
|
|
184
|
-
return NativeSDK.setRustoreToken(token);
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
// ---------------- subscription (public: unknown, native: string) ----------------
|
|
188
|
-
|
|
189
|
-
/** Push subscribe (fire-and-forget). */
|
|
190
|
-
export function pushSubscribe(sync = true, profileFields = null, customFields = null, cats = null, replace = null, skipTriggers = null) {
|
|
191
|
-
NativeSDK.pushSubscribe(sync, toNativeStringMap(profileFields), toNativeStringMap(customFields), cats, replace, skipTriggers);
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
/** Push suspend (fire-and-forget). */
|
|
195
|
-
export function pushSuspend(sync = true, profileFields = null, customFields = null, cats = null, replace = null, skipTriggers = null) {
|
|
196
|
-
NativeSDK.pushSuspend(sync, toNativeStringMap(profileFields), toNativeStringMap(customFields), cats, replace, skipTriggers);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/** Push unsubscribe (fire-and-forget). */
|
|
200
|
-
export function pushUnSubscribe(sync = true, profileFields = null, customFields = null, cats = null, replace = null, skipTriggers = null) {
|
|
201
|
-
NativeSDK.pushUnSubscribe(sync, toNativeStringMap(profileFields), toNativeStringMap(customFields), cats, replace, skipTriggers);
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
/** Un-suspends push subscription and returns response (if any). */
|
|
205
|
-
export function unSuspendPushSubscription() {
|
|
206
|
-
return NativeSDK.unSuspendPushSubscription();
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
/** Returns latest subscription status (if any). */
|
|
210
|
-
export function getStatusOfLatestSubscription() {
|
|
211
|
-
return NativeSDK.getStatusOfLatestSubscription();
|
|
212
|
-
}
|
|
213
|
-
|
|
214
|
-
/** Returns latest subscription status for a provider (if any). */
|
|
215
|
-
export function getStatusOfLatestSubscriptionForProvider(provider = null) {
|
|
216
|
-
return NativeSDK.getStatusOfLatestSubscriptionForProvider(provider);
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
/** Returns current subscription status (if any). */
|
|
220
|
-
export function getStatusForCurrentSubscription() {
|
|
221
|
-
return NativeSDK.getStatusForCurrentSubscription();
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
// ---------------- token public API ----------------
|
|
211
|
+
//Android-only behavior
|
|
225
212
|
|
|
226
|
-
|
|
227
|
-
export function getPushToken() {
|
|
228
|
-
return NativeSDK.getPushToken();
|
|
229
|
-
}
|
|
213
|
+
// ---------------- Push payload bridge ----------------
|
|
230
214
|
|
|
231
|
-
/**
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
/** Updates provider priority list. */
|
|
242
|
-
export function changePushProviderPriorityList(priorityList) {
|
|
243
|
-
return NativeSDK.changePushProviderPriorityList(priorityList);
|
|
244
|
-
}
|
|
245
|
-
|
|
246
|
-
/** Sets or clears token for a specific provider. */
|
|
247
|
-
export function setPushToken(provider, token) {
|
|
248
|
-
return NativeSDK.setPushToken(provider, token);
|
|
249
|
-
}
|
|
250
|
-
|
|
251
|
-
// ---------------- sdk wrappers ----------------
|
|
252
|
-
|
|
253
|
-
/** Clears SDK local state. */
|
|
254
|
-
export function clear() {
|
|
255
|
-
return NativeSDK.clear();
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
/** Resets session init-control state (platform-dependent). */
|
|
259
|
-
export function unlockInitOperationsInThisSession() {
|
|
260
|
-
return NativeSDK.unlockInitOperationsInThisSession();
|
|
215
|
+
/**
|
|
216
|
+
* Forwards a push payload to native SDK (Android-only behavior).
|
|
217
|
+
*
|
|
218
|
+
* @param message Push payload map (string-only).
|
|
219
|
+
*/
|
|
220
|
+
export function takePush(message) {
|
|
221
|
+
if (!message || Object.keys(message).length === 0) return;
|
|
222
|
+
NativeSDK.takePush({
|
|
223
|
+
...message
|
|
224
|
+
});
|
|
261
225
|
}
|
|
262
226
|
|
|
263
|
-
/**
|
|
227
|
+
/**
|
|
228
|
+
* Requests notification permission (Android-only behavior).
|
|
229
|
+
* On Android it may trigger runtime permission flow,
|
|
230
|
+
* n iOS it can be a no-op or routed to native implementation.
|
|
231
|
+
*/
|
|
264
232
|
export function requestNotificationPermission() {
|
|
265
233
|
return NativeSDK.requestNotificationPermission();
|
|
266
234
|
}
|
|
267
235
|
|
|
268
|
-
// ----------------
|
|
236
|
+
// ---------------- Manual push events ----------------
|
|
269
237
|
|
|
270
|
-
/**
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
// ---------------- MobileEvent (public: unknown, native: string) ----------------
|
|
277
|
-
|
|
278
|
-
/** Sends a mobile event (fire-and-forget). */
|
|
279
|
-
export function mobileEvent(sid, eventName, sendMessageId = null, payload = null, matching = null, matchingType = null, profileFields = null, utm = null) {
|
|
280
|
-
NativeSDK.mobileEvent(sid, eventName, sendMessageId, toNativeStringMap(payload), toNativeStringMap(matching), matchingType, toNativeStringMap(profileFields), utm);
|
|
281
|
-
}
|
|
282
|
-
|
|
283
|
-
/** Manually records a push delivery event (fire-and-forget). */
|
|
238
|
+
/**
|
|
239
|
+
* Reports an Altcraft push delivery event (Android-only behavior).
|
|
240
|
+
*
|
|
241
|
+
* @param message Optional push payload (string-only).
|
|
242
|
+
* @param messageUID Optional Altcraft message UID.
|
|
243
|
+
*/
|
|
284
244
|
export function deliveryEvent(message = null, messageUID = null) {
|
|
285
245
|
const nativePayload = message && Object.keys(message).length > 0 ? {
|
|
286
246
|
...message
|
|
287
247
|
} : null;
|
|
288
|
-
|
|
289
|
-
// Kept as runtime call for backward-compat if some platform exposes it outside codegen.
|
|
290
248
|
NativeSDK.deliveryEvent(nativePayload, messageUID);
|
|
291
249
|
}
|
|
292
250
|
|
|
293
|
-
/**
|
|
251
|
+
/**
|
|
252
|
+
* Reports an Altcraft push open event (Android-only behavior).
|
|
253
|
+
*
|
|
254
|
+
* @param message Optional push payload (string-only).
|
|
255
|
+
* @param messageUID Optional Altcraft message UID.
|
|
256
|
+
*/
|
|
294
257
|
export function openEvent(message = null, messageUID = null) {
|
|
295
258
|
const nativePayload = message && Object.keys(message).length > 0 ? {
|
|
296
259
|
...message
|
|
297
260
|
} : null;
|
|
298
|
-
|
|
299
|
-
// Kept as runtime call for backward-compat if some platform exposes it outside codegen.
|
|
300
261
|
NativeSDK.openEvent(nativePayload, messageUID);
|
|
301
262
|
}
|
|
302
263
|
|
|
264
|
+
// ---------------- UserDefaults ----------------
|
|
265
|
+
/**
|
|
266
|
+
* Stores a value into native UserDefaults (IOS-only behavior).
|
|
267
|
+
*
|
|
268
|
+
* @param suiteName iOS App Group suite name or `null` to use standard UserDefaults.
|
|
269
|
+
* @param key Storage key.
|
|
270
|
+
* @param value Any JS value; will be converted to string or removed when `null/undefined`.
|
|
271
|
+
*/
|
|
272
|
+
export function setUserDefaultsValue(suiteName, key, value) {
|
|
273
|
+
const str = Utilities.toUserDefaultsString(value);
|
|
274
|
+
return NativeSDK.setUserDefaultsValue(suiteName, key, str);
|
|
275
|
+
}
|
|
276
|
+
|
|
303
277
|
// ---------------- Default export ----------------
|
|
304
278
|
|
|
305
|
-
/**
|
|
279
|
+
/**
|
|
280
|
+
* Public React Native facade for the Altcraft SDK.
|
|
281
|
+
*
|
|
282
|
+
* Provides:
|
|
283
|
+
* - SDK initialization
|
|
284
|
+
* - Push subscription operations
|
|
285
|
+
* - Subscription status queries
|
|
286
|
+
* - SDK event stream via NativeEventEmitter
|
|
287
|
+
* - Mobile events
|
|
288
|
+
* - Push token access
|
|
289
|
+
* - Local storage bridge (UserDefaults/SharedPreferences)
|
|
290
|
+
*/
|
|
306
291
|
const AltcraftSDK = {
|
|
292
|
+
// SDK initialization
|
|
307
293
|
initialize,
|
|
308
|
-
|
|
294
|
+
// Push subscription
|
|
309
295
|
pushSubscribe,
|
|
310
296
|
pushSuspend,
|
|
311
297
|
pushUnSubscribe,
|
|
312
298
|
unSuspendPushSubscription,
|
|
299
|
+
// Profile status
|
|
313
300
|
getStatusOfLatestSubscription,
|
|
314
301
|
getStatusOfLatestSubscriptionForProvider,
|
|
315
302
|
getStatusForCurrentSubscription,
|
|
316
|
-
|
|
317
|
-
deleteDeviceToken,
|
|
318
|
-
forcedTokenUpdate,
|
|
319
|
-
changePushProviderPriorityList,
|
|
320
|
-
setPushToken,
|
|
321
|
-
mobileEvent,
|
|
303
|
+
// SDK events
|
|
322
304
|
subscribeToEvents,
|
|
323
305
|
unsubscribeFromEvent,
|
|
306
|
+
// Mobile events
|
|
307
|
+
mobileEvent,
|
|
308
|
+
// Push token
|
|
309
|
+
setPushToken,
|
|
310
|
+
getPushToken,
|
|
311
|
+
// Clear SDK data
|
|
324
312
|
clear,
|
|
325
|
-
//
|
|
326
|
-
setIosFcmToken,
|
|
327
|
-
setIosHmsToken,
|
|
328
|
-
setApnsToken,
|
|
313
|
+
// Set UserDefault / SharedPreferenses
|
|
329
314
|
setUserDefaultsValue,
|
|
330
|
-
//
|
|
331
|
-
setAndroidFcmToken,
|
|
332
|
-
setAndroidHmsToken,
|
|
333
|
-
setRustoreToken,
|
|
334
|
-
PushReceiver,
|
|
335
|
-
registerPushReceiver,
|
|
336
|
-
clearPushReceivers,
|
|
315
|
+
// Android only
|
|
337
316
|
takePush,
|
|
338
317
|
deliveryEvent,
|
|
339
318
|
openEvent,
|
|
340
|
-
unlockInitOperationsInThisSession,
|
|
341
319
|
requestNotificationPermission
|
|
342
320
|
};
|
|
343
321
|
export default AltcraftSDK;
|
package/lib/module/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeEventEmitter","NativeModules","NativeSDK","
|
|
1
|
+
{"version":3,"names":["NativeEventEmitter","NativeModules","NativeSDK","Utilities","initialize","config","pushSubscribe","sync","profileFields","customFields","cats","replace","skipTriggers","toNativeStringMap","pushSuspend","pushUnSubscribe","unSuspendPushSubscription","getStatusOfLatestSubscription","getStatusForCurrentSubscription","getStatusOfLatestSubscriptionForProvider","provider","getPushToken","setPushToken","token","clear","mobileEvent","sid","eventName","sendMessageId","payload","matching","matchingType","subscription","utm","subscriptionToNativeMap","ALTCRAFT_SDK_EVENT_NAME","nativeEventEmitter","SDKEventEmitter","eventsSubscription","subscribeToEvents","handler","remove","addListener","args","event","e","console","warn","unsubscribeFromEvent","takePush","message","Object","keys","length","requestNotificationPermission","deliveryEvent","messageUID","nativePayload","openEvent","setUserDefaultsValue","suiteName","key","value","str","toUserDefaultsString","AltcraftSDK"],"sourceRoot":"../../src","sources":["index.tsx"],"mappings":";;AAAA,SAASA,kBAAkB,EAAEC,aAAa,QAAQ,cAAc;AAEhE,OAAOC,SAAS,MAYT,gBAAa;AAEpB,SAASC,SAAS,QAAQ,gBAAa;;AAEvC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,UAAUA,CAACC,MAAsB,EAAiB;EAChE,OAAOH,SAAS,CAACE,UAAU,CAACC,MAAM,CAAC;AACrC;;AAEA;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,aAAaA,CAC3BC,IAAoB,GAAG,IAAI,EAC3BC,aAA6C,GAAG,IAAI,EACpDC,YAA4C,GAAG,IAAI,EACnDC,IAA2B,GAAG,IAAI,EAClCC,OAAuB,GAAG,IAAI,EAC9BC,YAA4B,GAAG,IAAI,EAC7B;EACNV,SAAS,CAACI,aAAa,CACrBC,IAAI,EACJJ,SAAS,CAACU,iBAAiB,CAACL,aAAa,CAAC,EAC1CL,SAAS,CAACU,iBAAiB,CAACJ,YAAY,CAAC,EACzCC,IAAI,EACJC,OAAO,EACPC,YACF,CAAC;AACH;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASE,WAAWA,CACzBP,IAAoB,GAAG,IAAI,EAC3BC,aAA6C,GAAG,IAAI,EACpDC,YAA4C,GAAG,IAAI,EACnDC,IAA2B,GAAG,IAAI,EAClCC,OAAuB,GAAG,IAAI,EAC9BC,YAA4B,GAAG,IAAI,EAC7B;EACNV,SAAS,CAACY,WAAW,CACnBP,IAAI,EACJJ,SAAS,CAACU,iBAAiB,CAACL,aAAa,CAAC,EAC1CL,SAAS,CAACU,iBAAiB,CAACJ,YAAY,CAAC,EACzCC,IAAI,EACJC,OAAO,EACPC,YACF,CAAC;AACH;;AAEA;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