@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
@@ -2,343 +2,433 @@
2
2
 
3
3
  import { NativeEventEmitter, NativeModules } from 'react-native';
4
4
  import NativeSDK from "./NativeSdk.js";
5
+ import { Utilities, ActionFieldBuilder, actionField } from "./Utilities.js";
5
6
 
6
- /** SDK event payload emitted from native via NativeEventEmitter ("AltcraftSdkEvent"). */
7
-
8
- /** UTM tags for mobileEvent attribution. */
9
-
10
- // ---------------- Utilities ----------------
11
-
12
- /** Converts a JS object to { [key: string]: string } for the RN bridge; drops null/undefined. */
13
- function toNativeStringMap(input) {
14
- if (input == null) return null;
15
- const out = {};
16
- for (const [key, value] of Object.entries(input)) {
17
- if (value == null) continue;
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;
37
- }
7
+ // ---------------- SDK API ----------------
38
8
 
39
9
  /**
40
- * New Arch safe:
41
- * TurboModule codegen does NOT support `any`.
42
- * Therefore, we serialize any value for UserDefaults into `string`:
43
- * - string -> as-is
44
- * - number/boolean -> String(...)
45
- * - object/array -> JSON.stringify(...)
46
- * - null/undefined -> null (native side can treat it as “remove key”)
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.
47
16
  */
48
- function toUserDefaultsString(value) {
49
- if (value == null) return null;
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
- }
17
+ export function initialize(config) {
18
+ return NativeSDK.initialize(config);
58
19
  }
59
20
 
60
- // ---------------- PushReceiver API (JS-side) ----------------
61
-
62
- /** JS handler interface for incoming push payloads. */
63
- export class PushReceiver {}
64
-
65
- /** Registered JS receivers for push payloads. */
66
- const registeredPushReceivers = [];
67
-
68
- /** Registers a JS push receiver. */
69
- export function registerPushReceiver(receiver) {
70
- registeredPushReceivers.push(receiver);
71
- }
21
+ // ---------------- Push subscription ----------------
72
22
 
73
- /** Clears all JS push receivers. */
74
- export function clearPushReceivers() {
75
- registeredPushReceivers.length = 0;
23
+ /**
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.
37
+ */
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);
76
40
  }
77
41
 
78
- /** Default receiver used when none are registered. */
79
- class DefaultPushReceiver extends PushReceiver {
80
- pushHandler(message) {
81
- // eslint-disable-next-line no-console
82
- console.log('[AltcraftSDK] Default push handler:', message);
83
- }
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);
84
54
  }
85
55
 
86
56
  /**
87
- * Forwards a push payload to native SDK and then to JS receivers.
88
- * This does not intercept system notifications by itself.
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.
89
65
  */
90
- export function takePush(message) {
91
- if (!message || Object.keys(message).length === 0) return;
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
- }
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);
104
68
  }
105
69
 
106
- // ---------------- Events API for RN ----------------
107
-
108
- /** RN subscription handle (NativeEventEmitter). */
70
+ // ---------------- Promise APIs ----------------
109
71
 
110
- /** Native emitter for "AltcraftSdkEvent". */
111
- const nativeEventEmitter = new NativeEventEmitter(NativeModules.SDKEventEmitter);
112
-
113
- /** Current JS-side subscription. */
114
- let eventsSubscription = null;
115
-
116
- /** Subscribes to native SDK events and routes them to the handler. */
117
- export function subscribeToEvents(handler) {
118
- if (eventsSubscription) {
119
- eventsSubscription.remove();
120
- eventsSubscription = null;
121
- }
122
- NativeSDK.subscribeToEvents();
123
- eventsSubscription = nativeEventEmitter.addListener('AltcraftSdkEvent', (...args) => {
124
- const event = args[0] ?? null;
125
- if (!event) return;
126
- try {
127
- handler(event);
128
- } catch (e) {
129
- console.warn('[AltcraftSDK] subscribeToEvents handler error:', e);
130
- }
131
- });
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();
132
79
  }
133
80
 
134
- /** Unsubscribes from native SDK events. */
135
- export function unsubscribeFromEvent() {
136
- if (eventsSubscription) {
137
- eventsSubscription.remove();
138
- eventsSubscription = null;
139
- }
140
- NativeSDK.unsubscribeFromEvent();
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();
141
88
  }
142
89
 
143
- // ---------------- SDK API ----------------
144
-
145
- /** Initializes the Altcraft SDK. */
146
- export function initialize(config) {
147
- return NativeSDK.initialize(config);
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();
148
97
  }
149
98
 
150
- /** Sets or clears the JWT used by the SDK. */
151
- export function setJwt(token) {
152
- return NativeSDK.setJwt(token);
99
+ /**
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.
106
+ */
107
+ export function getStatusOfLatestSubscriptionForProvider(provider = null) {
108
+ return NativeSDK.getStatusOfLatestSubscriptionForProvider(provider);
153
109
  }
154
110
 
155
- // platform-specific token setters
111
+ // ---------------- Token API ----------------
156
112
 
157
- /** Android-only: sets FCM token. */
158
- export function setAndroidFcmToken(token) {
159
- return NativeSDK.setAndroidFcmToken(token);
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();
160
120
  }
161
121
 
162
- /** iOS-only: sets FCM token. */
163
- export function setIosFcmToken(token) {
164
- return NativeSDK.setIosFcmToken(token);
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);
165
131
  }
166
132
 
167
- /** Android-only: sets HMS token. */
168
- export function setAndroidHmsToken(token) {
169
- return NativeSDK.setAndroidHmsToken(token);
170
- }
133
+ // ---------------- SDK wrappers ----------------
171
134
 
172
- /** iOS-only: sets HMS token. */
173
- export function setIosHmsToken(token) {
174
- return NativeSDK.setIosHmsToken(token);
135
+ /**
136
+ * Clears SDK local state (native).
137
+ *
138
+ * @returns Promise that resolves after cleanup.
139
+ */
140
+ export function clear() {
141
+ return NativeSDK.clear();
175
142
  }
176
143
 
177
- /** iOS-only: sets APNs token. */
178
- export function setApnsToken(token) {
179
- return NativeSDK.setApnsToken(token);
180
- }
144
+ // ---------------- MobileEvent ----------------
181
145
 
182
- /** Android-only: sets RuStore token. */
183
- export function setRustoreToken(token) {
184
- return NativeSDK.setRustoreToken(token);
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
+ campaign: null,
162
+ content: null,
163
+ keyword: null,
164
+ medium: null,
165
+ source: null,
166
+ temp: null
167
+ });
185
168
  }
186
169
 
187
- // ---------------- subscription (public: unknown, native: string) ----------------
170
+ // ---------------- SDK Event API ----------------
188
171
 
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);
172
+ const ALTCRAFT_SDK_EVENT_NAME = 'AltcraftSdkEvent';
173
+ const nativeEventEmitter = new NativeEventEmitter(NativeModules.SDKEventEmitter);
174
+ let eventsSubscription = null;
175
+ const eventHandlers = new Set();
176
+ function ensureNativeSubscription() {
177
+ if (eventsSubscription === null) {
178
+ NativeSDK.subscribeToEvents();
179
+ eventsSubscription = nativeEventEmitter.addListener(ALTCRAFT_SDK_EVENT_NAME, (...args) => {
180
+ const event = args[0] ?? null;
181
+ if (!event) return;
182
+ const handlers = Array.from(eventHandlers);
183
+ for (const handler of handlers) {
184
+ try {
185
+ handler(event);
186
+ } catch (e) {
187
+ console.warn('[AltcraftSDK] subscribeToEvents handler error:', e);
188
+ }
189
+ }
190
+ });
191
+ }
192
192
  }
193
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);
194
+ /**
195
+ * Subscribes to native SDK events and routes them to the provided handler.
196
+ *
197
+ * Multiple callers can subscribe independently — each handler receives every event.
198
+ * The native subscription is activated only once (first caller).
199
+ *
200
+ * @param handler Callback invoked for each incoming SDK event.
201
+ * The event object is produced by native and follows {@link SdkEvent}.
202
+ */
203
+ export function subscribeToEvents(handler) {
204
+ eventHandlers.add(handler);
205
+ ensureNativeSubscription();
197
206
  }
198
207
 
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);
208
+ /**
209
+ * Unsubscribes a specific handler from native SDK events.
210
+ *
211
+ * When the last handler is removed, the native subscription is also released.
212
+ * Safe to call even if not subscribed.
213
+ */
214
+ export function unsubscribeFromEvent(handler) {
215
+ if (handler) {
216
+ eventHandlers.delete(handler);
217
+ }
218
+ if (eventHandlers.size === 0) {
219
+ if (eventsSubscription) {
220
+ eventsSubscription.remove();
221
+ eventsSubscription = null;
222
+ }
223
+ NativeSDK.unsubscribeFromEvent();
224
+ }
202
225
  }
203
226
 
204
- /** Un-suspends push subscription and returns response (if any). */
205
- export function unSuspendPushSubscription() {
206
- return NativeSDK.unSuspendPushSubscription();
207
- }
227
+ //Android-only behavior
208
228
 
209
- /** Returns latest subscription status (if any). */
210
- export function getStatusOfLatestSubscription() {
211
- return NativeSDK.getStatusOfLatestSubscription();
212
- }
229
+ // ---------------- Push payload bridge ----------------
213
230
 
214
- /** Returns latest subscription status for a provider (if any). */
215
- export function getStatusOfLatestSubscriptionForProvider(provider = null) {
216
- return NativeSDK.getStatusOfLatestSubscriptionForProvider(provider);
231
+ /**
232
+ * Forwards a push payload to native SDK (Android-only behavior).
233
+ *
234
+ * @param message Push payload map (string-only).
235
+ */
236
+ export function takePush(message) {
237
+ if (!message || Object.keys(message).length === 0) return;
238
+ NativeSDK.takePush({
239
+ ...message
240
+ });
217
241
  }
218
242
 
219
- /** Returns current subscription status (if any). */
220
- export function getStatusForCurrentSubscription() {
221
- return NativeSDK.getStatusForCurrentSubscription();
243
+ /**
244
+ * Requests notification permission (Android-only behavior).
245
+ * On Android it may trigger runtime permission flow,
246
+ * n iOS it can be a no-op or routed to native implementation.
247
+ */
248
+ export function requestNotificationPermission() {
249
+ return NativeSDK.requestNotificationPermission();
222
250
  }
223
251
 
224
- // ---------------- token public API ----------------
252
+ // ---------------- Manual push events ----------------
225
253
 
226
- /** Returns current push token (or null). */
227
- export function getPushToken() {
228
- return NativeSDK.getPushToken();
254
+ /**
255
+ * Reports an Altcraft push delivery event (Android-only behavior).
256
+ *
257
+ * @param message Optional push payload (string-only).
258
+ * @param messageUID Optional Altcraft message UID.
259
+ */
260
+ export function deliveryEvent(message = null, messageUID = null) {
261
+ const nativePayload = message && Object.keys(message).length > 0 ? {
262
+ ...message
263
+ } : null;
264
+ NativeSDK.deliveryEvent(nativePayload, messageUID);
229
265
  }
230
266
 
231
- /** Deletes device token for provider. */
232
- export function deleteDeviceToken(provider) {
233
- return NativeSDK.deleteDeviceToken(provider);
267
+ /**
268
+ * Reports an Altcraft push open event (Android-only behavior).
269
+ *
270
+ * @param message Optional push payload (string-only).
271
+ * @param messageUID Optional Altcraft message UID.
272
+ */
273
+ export function openEvent(message = null, messageUID = null) {
274
+ const nativePayload = message && Object.keys(message).length > 0 ? {
275
+ ...message
276
+ } : null;
277
+ NativeSDK.openEvent(nativePayload, messageUID);
234
278
  }
235
279
 
236
- /** Forces token refresh flow. */
237
- export function forcedTokenUpdate() {
238
- return NativeSDK.forcedTokenUpdate();
280
+ // ---------------- UserDefaults ----------------
281
+ /**
282
+ * Stores a value into native UserDefaults (IOS-only behavior).
283
+ *
284
+ * @param suiteName iOS App Group suite name or `null` to use standard UserDefaults.
285
+ * @param key Storage key.
286
+ * @param value Any JS value; will be converted to string or removed when `null/undefined`.
287
+ */
288
+ export function setUserDefaultsValue(suiteName, key, value) {
289
+ const str = Utilities.toUserDefaultsString(value);
290
+ return NativeSDK.setUserDefaultsValue(suiteName, key, str);
239
291
  }
240
292
 
241
- /** Updates provider priority list. */
242
- export function changePushProviderPriorityList(priorityList) {
243
- return NativeSDK.changePushProviderPriorityList(priorityList);
244
- }
293
+ // ---------------- Profile API ----------------
245
294
 
246
- /** Sets or clears token for a specific provider. */
247
- export function setPushToken(provider, token) {
248
- return NativeSDK.setPushToken(provider, token);
295
+ /**
296
+ * Updates profile fields on the server.
297
+ *
298
+ * @param profileFields Optional profile fields to update.
299
+ * @param skipTriggers Optional flag to skip trigger execution on the server.
300
+ */
301
+ export function updateProfileFields(profileFields = null, skipTriggers = null) {
302
+ NativeSDK.updateProfileFields(Utilities.toNativeStringMap(profileFields), skipTriggers);
249
303
  }
250
304
 
251
- // ---------------- sdk wrappers ----------------
252
-
253
- /** Clears SDK local state. */
254
- export function clear() {
255
- return NativeSDK.clear();
256
- }
305
+ // ---------------- Token management API ----------------
257
306
 
258
- /** Resets session init-control state (platform-dependent). */
259
- export function unlockInitOperationsInThisSession() {
260
- return NativeSDK.unlockInitOperationsInThisSession();
307
+ /**
308
+ * Forces a push token refresh (delete current token + re-register).
309
+ *
310
+ * @returns Promise that resolves when the token update flow completes.
311
+ */
312
+ export function forcedTokenUpdate() {
313
+ return NativeSDK.forcedTokenUpdate();
261
314
  }
262
315
 
263
- /** Requests notification permission (platform-dependent). */
264
- export function requestNotificationPermission() {
265
- return NativeSDK.requestNotificationPermission();
316
+ /**
317
+ * Deletes the device token for a given provider.
318
+ *
319
+ * @param provider Provider identifier (e.g. `android-firebase`, `ios-firebase`).
320
+ * @returns Promise that resolves when the delete call completes.
321
+ */
322
+ export function deleteDeviceToken(provider) {
323
+ return NativeSDK.deleteDeviceToken(provider);
266
324
  }
267
325
 
268
- // ---------------- UserDefaults / SharedPreferences ----------------
269
-
270
- /** Stores a value into native UserDefaults / SharedPreferences (platform-dependent). */
271
- export function setUserDefaultsValue(suiteName, key, value) {
272
- const str = toUserDefaultsString(value);
273
- return NativeSDK.setUserDefaultsValue(suiteName, key, str);
326
+ /**
327
+ * Changes the push provider priority list at runtime.
328
+ *
329
+ * @param priorityList Ordered list of provider identifiers.
330
+ * @returns Promise that resolves when the priority list is updated.
331
+ */
332
+ export function changePushProviderPriorityList(priorityList) {
333
+ if (!priorityList || priorityList.length === 0) {
334
+ return Promise.resolve();
335
+ }
336
+ return NativeSDK.changePushProviderPriorityList(priorityList);
274
337
  }
275
338
 
276
- // ---------------- MobileEvent (public: unknown, native: string) ----------------
339
+ // ---------------- PushReceiver helpers ----------------
277
340
 
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);
341
+ /**
342
+ * Checks whether a push payload belongs to Altcraft.
343
+ *
344
+ * @param message Push payload map (string-only).
345
+ * @returns `true` if the message contains the Altcraft marker key.
346
+ */
347
+ export function isAltcraftPush(message) {
348
+ if (!message || Object.keys(message).length === 0) return false;
349
+ return NativeSDK.isAltcraftPush({
350
+ ...message
351
+ });
281
352
  }
282
353
 
283
- /** Manually records a push delivery event (fire-and-forget). */
284
- export function deliveryEvent(message = null, messageUID = null) {
285
- const nativePayload = message && Object.keys(message).length > 0 ? {
286
- ...message
287
- } : null;
354
+ // ---------------- SDK lifecycle ----------------
288
355
 
289
- // Kept as runtime call for backward-compat if some platform exposes it outside codegen.
290
- NativeSDK.deliveryEvent(nativePayload, messageUID);
356
+ /**
357
+ * Allows re-running initial retry/scheduling/token-check logic
358
+ * in this process on the next initialization (Android only).
359
+ * No-op on iOS.
360
+ */
361
+ export function unlockInitialOperationsInThisSession() {
362
+ NativeSDK.unlockInitialOperationsInThisSession();
291
363
  }
292
364
 
293
- /** Manually records a push open event (fire-and-forget). */
294
- export function openEvent(message = null, messageUID = null) {
295
- const nativePayload = message && Object.keys(message).length > 0 ? {
296
- ...message
297
- } : null;
365
+ // ---------------- iOS-only ----------------
298
366
 
299
- // Kept as runtime call for backward-compat if some platform exposes it outside codegen.
300
- NativeSDK.openEvent(nativePayload, messageUID);
367
+ /**
368
+ * Sets the App Group name for shared UserDefaults and Core Data (iOS only).
369
+ * Must be called before SDK initialization.
370
+ *
371
+ * @param groupName App Group identifier or `null` to clear.
372
+ */
373
+ export function setAppGroup(groupName) {
374
+ NativeSDK.setAppGroup(groupName);
301
375
  }
302
376
 
303
377
  // ---------------- Default export ----------------
304
378
 
305
- /** Public React Native facade for the Altcraft SDK. */
379
+ /**
380
+ * Public React Native facade for the Altcraft SDK.
381
+ *
382
+ * Provides:
383
+ * - SDK initialization
384
+ * - Push subscription operations
385
+ * - Subscription status queries
386
+ * - SDK event stream via NativeEventEmitter
387
+ * - Mobile events
388
+ * - Push token access
389
+ * - Local storage bridge (UserDefaults/SharedPreferences)
390
+ */
306
391
  const AltcraftSDK = {
392
+ // SDK initialization
307
393
  initialize,
308
- setJwt,
394
+ // Push subscription
309
395
  pushSubscribe,
310
396
  pushSuspend,
311
397
  pushUnSubscribe,
312
398
  unSuspendPushSubscription,
399
+ // Profile status
313
400
  getStatusOfLatestSubscription,
314
401
  getStatusOfLatestSubscriptionForProvider,
315
402
  getStatusForCurrentSubscription,
316
- getPushToken,
317
- deleteDeviceToken,
318
- forcedTokenUpdate,
319
- changePushProviderPriorityList,
320
- setPushToken,
321
- mobileEvent,
403
+ // SDK events
322
404
  subscribeToEvents,
323
405
  unsubscribeFromEvent,
406
+ // Mobile events
407
+ mobileEvent,
408
+ // Push token
409
+ setPushToken,
410
+ getPushToken,
411
+ // Clear SDK data
324
412
  clear,
325
- //ios only
326
- setIosFcmToken,
327
- setIosHmsToken,
328
- setApnsToken,
413
+ // Set UserDefault / SharedPreferenses
329
414
  setUserDefaultsValue,
330
- //android only
331
- setAndroidFcmToken,
332
- setAndroidHmsToken,
333
- setRustoreToken,
334
- PushReceiver,
335
- registerPushReceiver,
336
- clearPushReceivers,
415
+ // Android only
337
416
  takePush,
338
417
  deliveryEvent,
339
418
  openEvent,
340
- unlockInitOperationsInThisSession,
341
- requestNotificationPermission
419
+ requestNotificationPermission,
420
+ unlockInitialOperationsInThisSession,
421
+ // Profile API
422
+ updateProfileFields,
423
+ // Token management
424
+ forcedTokenUpdate,
425
+ deleteDeviceToken,
426
+ changePushProviderPriorityList,
427
+ // PushReceiver helpers
428
+ isAltcraftPush,
429
+ // iOS only
430
+ setAppGroup
342
431
  };
343
432
  export default AltcraftSDK;
433
+ export { ActionFieldBuilder, actionField };
344
434
  //# sourceMappingURL=index.js.map