@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.
Files changed (33) hide show
  1. package/LICENSE +20 -20
  2. package/README.md +5 -2
  3. package/android/build.gradle +2 -3
  4. package/android/src/main/java/com/altcraft/sdk/SdkModule.kt +551 -478
  5. package/android/src/main/java/com/altcraft/sdk/utilities/Converter.kt +164 -0
  6. package/android/src/main/java/com/altcraft/sdk/utilities/Extension.kt +72 -0
  7. package/ios/Converter.swift +483 -46
  8. package/ios/Sdk.mm +83 -271
  9. package/ios/SdkModule.swift +335 -493
  10. package/lib/module/NativeSdk.js +35 -0
  11. package/lib/module/NativeSdk.js.map +1 -1
  12. package/lib/module/Utilities.js +94 -0
  13. package/lib/module/Utilities.js.map +1 -0
  14. package/lib/module/index.js +224 -246
  15. package/lib/module/index.js.map +1 -1
  16. package/lib/typescript/src/NativeSdk.d.ts +107 -31
  17. package/lib/typescript/src/NativeSdk.d.ts.map +1 -1
  18. package/lib/typescript/src/Utilities.d.ts +15 -0
  19. package/lib/typescript/src/Utilities.d.ts.map +1 -0
  20. package/lib/typescript/src/index.d.ts +162 -94
  21. package/lib/typescript/src/index.d.ts.map +1 -1
  22. package/package.json +2 -2
  23. package/src/NativeSdk.ts +135 -44
  24. package/src/Utilities.ts +116 -0
  25. package/src/index.tsx +281 -311
  26. package/android/src/main/java/com/altcraft/sdk/interfaces/RnFCMProvider.kt +0 -26
  27. package/android/src/main/java/com/altcraft/sdk/interfaces/RnHMSProvider.kt +0 -32
  28. package/android/src/main/java/com/altcraft/sdk/interfaces/RnJWTProvider.kt +0 -21
  29. package/android/src/main/java/com/altcraft/sdk/interfaces/RnRustoreProvider.kt +0 -53
  30. package/ios/protocols/RNAPNSProvider.swift +0 -15
  31. package/ios/protocols/RNFCMProvider.swift +0 -24
  32. package/ios/protocols/RNHMSProvider.swift +0 -24
  33. package/ios/protocols/RNJWTProvider.swift +0 -15
package/src/index.tsx CHANGED
@@ -5,233 +5,48 @@ import NativeSDK, {
5
5
  type CategoryData,
6
6
  type ResponseWithHttpCode,
7
7
  type TokenData,
8
+ type EmailSubscription,
9
+ type SmsSubscription,
10
+ type PushSubscription,
11
+ type CcDataSubscription,
12
+ type Subscription,
13
+ type UTM,
14
+ type SdkEvent,
8
15
  } from './NativeSdk';
9
16
 
10
- /** SDK event payload emitted from native via NativeEventEmitter ("AltcraftSdkEvent"). */
11
- export type SdkEvent = {
12
- function: string;
13
- code: number | null;
14
- message: string;
15
- type: 'event' | 'error' | 'retryError';
16
- value?: Record<string, unknown> | null;
17
- };
18
-
19
- /** UTM tags for mobileEvent attribution. */
20
- export type UTM = {
21
- campaign?: string | null;
22
- content?: string | null;
23
- keyword?: string | null;
24
- medium?: string | null;
25
- source?: string | null;
26
- temp?: string | null;
27
- };
28
-
29
- // ---------------- Utilities ----------------
30
-
31
- /** Converts a JS object to { [key: string]: string } for the RN bridge; drops null/undefined. */
32
- function toNativeStringMap(
33
- input: Record<string, unknown> | null
34
- ): Record<string, string> | null {
35
- if (input == null) return null;
36
-
37
- const out: Record<string, string> = {};
38
-
39
- for (const [key, value] of Object.entries(input)) {
40
- if (value == null) continue;
41
-
42
- switch (typeof value) {
43
- case 'string':
44
- out[key] = value;
45
- break;
46
-
47
- case 'number':
48
- case 'boolean':
49
- case 'bigint':
50
- out[key] = String(value);
51
- break;
52
-
53
- default:
54
- try {
55
- out[key] = JSON.stringify(value);
56
- } catch {
57
- out[key] = String(value);
58
- }
59
- break;
60
- }
61
- }
62
-
63
- return Object.keys(out).length > 0 ? out : null;
64
- }
17
+ import { Utilities } from './Utilities';
65
18
 
66
- /**
67
- * New Arch safe:
68
- * TurboModule codegen does NOT support `any`.
69
- * Therefore, we serialize any value for UserDefaults into `string`:
70
- * - string -> as-is
71
- * - number/boolean -> String(...)
72
- * - object/array -> JSON.stringify(...)
73
- * - null/undefined -> null (native side can treat it as “remove key”)
74
- */
75
- function toUserDefaultsString(value: unknown): string | null {
76
- if (value == null) return null;
77
-
78
- const t = typeof value;
79
-
80
- if (t === 'string') return String(value);
81
- if (t === 'number' || t === 'boolean') return String(value);
82
-
83
- try {
84
- return JSON.stringify(value);
85
- } catch {
86
- return String(value);
87
- }
88
- }
89
-
90
- // ---------------- PushReceiver API (JS-side) ----------------
91
-
92
- /** JS handler interface for incoming push payloads. */
93
- export abstract class PushReceiver {
94
- /** Called with a flat push payload map. */
95
- abstract pushHandler(message: Record<string, string>): void;
96
- }
97
-
98
- /** Registered JS receivers for push payloads. */
99
- const registeredPushReceivers: PushReceiver[] = [];
100
-
101
- /** Registers a JS push receiver. */
102
- export function registerPushReceiver(receiver: PushReceiver): void {
103
- registeredPushReceivers.push(receiver);
104
- }
105
-
106
- /** Clears all JS push receivers. */
107
- export function clearPushReceivers(): void {
108
- registeredPushReceivers.length = 0;
109
- }
110
-
111
- /** Default receiver used when none are registered. */
112
- class DefaultPushReceiver extends PushReceiver {
113
- override pushHandler(message: Record<string, string>): void {
114
- // eslint-disable-next-line no-console
115
- console.log('[AltcraftSDK] Default push handler:', message);
116
- }
117
- }
19
+ // ---------------- SDK API ----------------
118
20
 
119
21
  /**
120
- * Forwards a push payload to native SDK and then to JS receivers.
121
- * This does not intercept system notifications by itself.
22
+ * Initializes the Altcraft SDK.
23
+ *
24
+ * @param config SDK configuration.
25
+ * `apiUrl` is required.
26
+ * Other fields are optional and depend on platform features.
27
+ * @returns Promise that resolves on successful initialization.
122
28
  */
123
- export function takePush(message: Record<string, string>): void {
124
- if (!message || Object.keys(message).length === 0) return;
125
-
126
- NativeSDK.takePush({ ...message });
127
-
128
- const receivers =
129
- registeredPushReceivers.length > 0
130
- ? registeredPushReceivers
131
- : [new DefaultPushReceiver()];
132
-
133
- for (const receiver of receivers) {
134
- try {
135
- receiver.pushHandler(message);
136
- } catch (e) {
137
- // eslint-disable-next-line no-console
138
- console.warn('[AltcraftSDK] PushReceiver error:', e);
139
- }
140
- }
141
- }
142
-
143
- // ---------------- Events API for RN ----------------
144
-
145
- /** RN subscription handle (NativeEventEmitter). */
146
- type EventsSubscription = { remove: () => void } | null;
147
-
148
- /** Native emitter for "AltcraftSdkEvent". */
149
- const nativeEventEmitter = new NativeEventEmitter(NativeModules.SDKEventEmitter);
150
-
151
- /** Current JS-side subscription. */
152
- let eventsSubscription: EventsSubscription = null;
153
-
154
- /** Subscribes to native SDK events and routes them to the handler. */
155
- export function subscribeToEvents(handler: (event: SdkEvent) => void): void {
156
- if (eventsSubscription) {
157
- eventsSubscription.remove();
158
- eventsSubscription = null;
159
- }
160
-
161
- NativeSDK.subscribeToEvents();
162
-
163
- eventsSubscription = nativeEventEmitter.addListener(
164
- 'AltcraftSdkEvent',
165
- (...args: unknown[]) => {
166
- const event = (args[0] ?? null) as SdkEvent | null;
167
- if (!event) return;
168
-
169
- try {
170
- handler(event);
171
- } catch (e) {
172
- console.warn('[AltcraftSDK] subscribeToEvents handler error:', e);
173
- }
174
- }
175
- );
176
- }
177
-
178
- /** Unsubscribes from native SDK events. */
179
- export function unsubscribeFromEvent(): void {
180
- if (eventsSubscription) {
181
- eventsSubscription.remove();
182
- eventsSubscription = null;
183
- }
184
-
185
- NativeSDK.unsubscribeFromEvent();
186
- }
187
-
188
- // ---------------- SDK API ----------------
189
-
190
- /** Initializes the Altcraft SDK. */
191
29
  export function initialize(config: AltcraftConfig): Promise<void> {
192
30
  return NativeSDK.initialize(config);
193
31
  }
194
32
 
195
- /** Sets or clears the JWT used by the SDK. */
196
- export function setJwt(token: string | null): void {
197
- return NativeSDK.setJwt(token);
198
- }
199
-
200
- // platform-specific token setters
201
-
202
- /** Android-only: sets FCM token. */
203
- export function setAndroidFcmToken(token: string | null): void {
204
- return NativeSDK.setAndroidFcmToken(token);
205
- }
206
-
207
- /** iOS-only: sets FCM token. */
208
- export function setIosFcmToken(token: string | null): void {
209
- return NativeSDK.setIosFcmToken(token);
210
- }
211
-
212
- /** Android-only: sets HMS token. */
213
- export function setAndroidHmsToken(token: string | null): void {
214
- return NativeSDK.setAndroidHmsToken(token);
215
- }
216
-
217
- /** iOS-only: sets HMS token. */
218
- export function setIosHmsToken(token: string | null): void {
219
- return NativeSDK.setIosHmsToken(token);
220
- }
221
-
222
- /** iOS-only: sets APNs token. */
223
- export function setApnsToken(token: string | null): void {
224
- return NativeSDK.setApnsToken(token);
225
- }
226
-
227
- /** Android-only: sets RuStore token. */
228
- export function setRustoreToken(token: string | null): void {
229
- return NativeSDK.setRustoreToken(token);
230
- }
33
+ // ---------------- Push subscription ----------------
231
34
 
232
- // ---------------- subscription (public: unknown, native: string) ----------------
233
-
234
- /** Push subscribe (fire-and-forget). */
35
+ /**
36
+ * Sends a push subscribe request.
37
+ *
38
+ * @param sync Execution mode:
39
+ * `true` — sends a synchronous request to the server and returns
40
+ * the result of the operation execution.
41
+ * `false` — sends an asynchronous request and returns
42
+ * the result of task enqueueing on the server.
43
+ * `null` — native default behavior.
44
+ * @param profileFields Optional profile fields to attach to the request.
45
+ * @param customFields Optional custom fields to attach to the request.
46
+ * @param cats Optional categories list.
47
+ * @param replace Optional flag to replace an existing subscription.
48
+ * @param skipTriggers Optional flag to skip trigger execution on the server.
49
+ */
235
50
  export function pushSubscribe(
236
51
  sync: boolean | null = true,
237
52
  profileFields: Record<string, unknown> | null = null,
@@ -242,15 +57,24 @@ export function pushSubscribe(
242
57
  ): void {
243
58
  NativeSDK.pushSubscribe(
244
59
  sync,
245
- toNativeStringMap(profileFields),
246
- toNativeStringMap(customFields),
60
+ Utilities.toNativeStringMap(profileFields),
61
+ Utilities.toNativeStringMap(customFields),
247
62
  cats,
248
63
  replace,
249
64
  skipTriggers
250
65
  );
251
66
  }
252
67
 
253
- /** Push suspend (fire-and-forget). */
68
+ /**
69
+ * Sends a push suspend request.
70
+ *
71
+ * @param sync Execution mode (see {@link pushSubscribe}).
72
+ * @param profileFields Optional profile fields.
73
+ * @param customFields Optional custom fields.
74
+ * @param cats Optional categories list.
75
+ * @param replace Optional flag to replace an existing subscription.
76
+ * @param skipTriggers Optional flag to skip trigger execution on the server.
77
+ */
254
78
  export function pushSuspend(
255
79
  sync: boolean | null = true,
256
80
  profileFields: Record<string, unknown> | null = null,
@@ -261,15 +85,24 @@ export function pushSuspend(
261
85
  ): void {
262
86
  NativeSDK.pushSuspend(
263
87
  sync,
264
- toNativeStringMap(profileFields),
265
- toNativeStringMap(customFields),
88
+ Utilities.toNativeStringMap(profileFields),
89
+ Utilities.toNativeStringMap(customFields),
266
90
  cats,
267
91
  replace,
268
92
  skipTriggers
269
93
  );
270
94
  }
271
95
 
272
- /** Push unsubscribe (fire-and-forget). */
96
+ /**
97
+ * Sends a push unsubscribe request.
98
+ *
99
+ * @param sync Execution mode (see {@link pushSubscribe}).
100
+ * @param profileFields Optional profile fields.
101
+ * @param customFields Optional custom fields.
102
+ * @param cats Optional categories list.
103
+ * @param replace Optional flag to replace an existing subscription.
104
+ * @param skipTriggers Optional flag to skip trigger execution on the server.
105
+ */
273
106
  export function pushUnSubscribe(
274
107
  sync: boolean | null = true,
275
108
  profileFields: Record<string, unknown> | null = null,
@@ -280,97 +113,106 @@ export function pushUnSubscribe(
280
113
  ): void {
281
114
  NativeSDK.pushUnSubscribe(
282
115
  sync,
283
- toNativeStringMap(profileFields),
284
- toNativeStringMap(customFields),
116
+ Utilities.toNativeStringMap(profileFields),
117
+ Utilities.toNativeStringMap(customFields),
285
118
  cats,
286
119
  replace,
287
120
  skipTriggers
288
121
  );
289
122
  }
290
123
 
291
- /** Un-suspends push subscription and returns response (if any). */
124
+ // ---------------- Promise APIs ----------------
125
+
126
+ /**
127
+ * Unsuspends push subscriptions based on native matching rules.
128
+ *
129
+ * @returns Promise resolving to response with HTTP code or `null` if unavailable.
130
+ */
292
131
  export function unSuspendPushSubscription(): Promise<ResponseWithHttpCode | null> {
293
132
  return NativeSDK.unSuspendPushSubscription();
294
133
  }
295
134
 
296
- /** Returns latest subscription status (if any). */
135
+ /**
136
+ * Returns the status of the latest subscription in profile.
137
+ *
138
+ * @returns Promise resolving to response with HTTP code or `null` if unavailable.
139
+ */
297
140
  export function getStatusOfLatestSubscription(): Promise<ResponseWithHttpCode | null> {
298
141
  return NativeSDK.getStatusOfLatestSubscription();
299
142
  }
300
143
 
301
- /** Returns latest subscription status for a provider (if any). */
144
+ /**
145
+ * Returns the status of the subscription matching the current push token and provider context.
146
+ *
147
+ * @returns Promise resolving to response with HTTP code or `null` if unavailable.
148
+ */
149
+ export function getStatusForCurrentSubscription(): Promise<ResponseWithHttpCode | null> {
150
+ return NativeSDK.getStatusForCurrentSubscription();
151
+ }
152
+
153
+ /**
154
+ * Returns the status of the latest subscription for the given provider.
155
+ *
156
+ * If `provider` is `null`, native side may use the current provider context.
157
+ *
158
+ * @param provider Optional provider identifier (platform-dependent).
159
+ * @returns Promise resolving to response with HTTP code or `null` if unavailable.
160
+ */
302
161
  export function getStatusOfLatestSubscriptionForProvider(
303
162
  provider: string | null = null
304
163
  ): Promise<ResponseWithHttpCode | null> {
305
164
  return NativeSDK.getStatusOfLatestSubscriptionForProvider(provider);
306
165
  }
307
166
 
308
- /** Returns current subscription status (if any). */
309
- export function getStatusForCurrentSubscription(): Promise<ResponseWithHttpCode | null> {
310
- return NativeSDK.getStatusForCurrentSubscription();
311
- }
312
-
313
- // ---------------- token public API ----------------
167
+ // ---------------- Token API ----------------
314
168
 
315
- /** Returns current push token (or null). */
169
+ /**
170
+ * Returns the current push token data from native side.
171
+ *
172
+ * @returns Promise resolving to token info or `null` if token is not available.
173
+ */
316
174
  export function getPushToken(): Promise<TokenData | null> {
317
175
  return NativeSDK.getPushToken();
318
176
  }
319
177
 
320
- /** Deletes device token for provider. */
321
- export function deleteDeviceToken(provider: string | null): Promise<void> {
322
- return NativeSDK.deleteDeviceToken(provider);
323
- }
324
-
325
- /** Forces token refresh flow. */
326
- export function forcedTokenUpdate(): Promise<void> {
327
- return NativeSDK.forcedTokenUpdate();
328
- }
329
-
330
- /** Updates provider priority list. */
331
- export function changePushProviderPriorityList(
332
- priorityList: string[] | null
333
- ): Promise<void> {
334
- return NativeSDK.changePushProviderPriorityList(priorityList);
335
- }
336
-
337
- /** Sets or clears token for a specific provider. */
178
+ /**
179
+ * Sets or clears the push token for a specific provider.
180
+ *
181
+ * @param provider Provider identifier (e.g. platform push provider name).
182
+ * @param token Token string or `null` to clear.
183
+ * @returns Promise that resolves when the token is saved on native side.
184
+ */
338
185
  export function setPushToken(provider: string, token: string | null): Promise<void> {
339
186
  return NativeSDK.setPushToken(provider, token);
340
187
  }
341
188
 
342
- // ---------------- sdk wrappers ----------------
189
+ // ---------------- SDK wrappers ----------------
343
190
 
344
- /** Clears SDK local state. */
191
+ /**
192
+ * Clears SDK local state (native).
193
+ *
194
+ * @returns Promise that resolves after cleanup.
195
+ */
345
196
  export function clear(): Promise<void> {
346
197
  return NativeSDK.clear();
347
198
  }
348
199
 
349
- /** Resets session init-control state (platform-dependent). */
350
- export function unlockInitOperationsInThisSession(): void {
351
- return NativeSDK.unlockInitOperationsInThisSession();
352
- }
353
-
354
- /** Requests notification permission (platform-dependent). */
355
- export function requestNotificationPermission(): void {
356
- return NativeSDK.requestNotificationPermission();
357
- }
358
-
359
- // ---------------- UserDefaults / SharedPreferences ----------------
360
-
361
- /** Stores a value into native UserDefaults / SharedPreferences (platform-dependent). */
362
- export function setUserDefaultsValue(
363
- suiteName: string | null,
364
- key: string,
365
- value: unknown
366
- ): void {
367
- const str = toUserDefaultsString(value);
368
- return NativeSDK.setUserDefaultsValue(suiteName, key, str);
369
- }
370
200
 
371
- // ---------------- MobileEvent (public: unknown, native: string) ----------------
201
+ // ---------------- MobileEvent ----------------
372
202
 
373
- /** Sends a mobile event (fire-and-forget). */
203
+ /**
204
+ * Sends a mobile event to the server.
205
+ *
206
+ * @param sid Pixel identifier.
207
+ * @param eventName Event name.
208
+ * @param sendMessageId Optional message identifier to link the event.
209
+ * @param payload Optional event payload.
210
+ * @param matching Optional matching parameters.
211
+ * @param matchingType Optional matching mode/type.
212
+ * @param profileFields Optional profile fields.
213
+ * @param subscription Optional subscription info to attach (email/sms/push/cc_data).
214
+ * @param utm Optional UTM tags for attribution.
215
+ */
374
216
  export function mobileEvent(
375
217
  sid: string,
376
218
  eventName: string,
@@ -379,21 +221,110 @@ export function mobileEvent(
379
221
  matching: Record<string, unknown> | null = null,
380
222
  matchingType: string | null = null,
381
223
  profileFields: Record<string, unknown> | null = null,
224
+ subscription: Subscription | null = null,
382
225
  utm: UTM | null = null
383
226
  ): void {
384
227
  NativeSDK.mobileEvent(
385
228
  sid,
386
229
  eventName,
387
230
  sendMessageId,
388
- toNativeStringMap(payload),
389
- toNativeStringMap(matching),
231
+ Utilities.toNativeStringMap(payload),
232
+ Utilities.toNativeStringMap(matching),
390
233
  matchingType,
391
- toNativeStringMap(profileFields),
234
+ Utilities.toNativeStringMap(profileFields),
235
+ Utilities.subscriptionToNativeMap(subscription),
392
236
  utm
393
237
  );
394
238
  }
395
239
 
396
- /** Manually records a push delivery event (fire-and-forget). */
240
+ // ---------------- SDK Event API ----------------
241
+
242
+ type EventsSubscription = { remove: () => void } | null;
243
+ const ALTCRAFT_SDK_EVENT_NAME = 'AltcraftSdkEvent' as const;
244
+ const nativeEventEmitter = new NativeEventEmitter(
245
+ NativeModules.SDKEventEmitter
246
+ );
247
+ let eventsSubscription: EventsSubscription = null;
248
+
249
+ /**
250
+ * Subscribes to native SDK events and routes them to the provided handler.
251
+ *
252
+ * The SDK emits events via `NativeEventEmitter` with name {@link ALTCRAFT_SDK_EVENT_NAME}.
253
+ * Calling this function multiple times replaces the previous JS listener.
254
+ *
255
+ * @param handler Callback invoked for each incoming SDK event.
256
+ * The event object is produced by native and follows {@link SdkEvent}.
257
+ */
258
+ export function subscribeToEvents(handler: (event: SdkEvent) => void): void {
259
+ if (eventsSubscription) {
260
+ eventsSubscription.remove();
261
+ eventsSubscription = null;
262
+ }
263
+
264
+ // Enables native-side subscription (starts producing events).
265
+ NativeSDK.subscribeToEvents();
266
+
267
+ eventsSubscription = nativeEventEmitter.addListener(
268
+ ALTCRAFT_SDK_EVENT_NAME,
269
+ (...args: unknown[]) => {
270
+ const event = (args[0] ?? null) as SdkEvent | null;
271
+ if (!event) return;
272
+
273
+ try {
274
+ handler(event);
275
+ } catch (e) {
276
+ console.warn('[AltcraftSDK] subscribeToEvents handler error:', e);
277
+ }
278
+ }
279
+ );
280
+ }
281
+
282
+ /**
283
+ * Unsubscribes from native SDK events.
284
+ *
285
+ * Removes the JS listener and instructs native module to stop emitting events.
286
+ * Safe to call even if not subscribed.
287
+ */
288
+ export function unsubscribeFromEvent(): void {
289
+ if (eventsSubscription) {
290
+ eventsSubscription.remove();
291
+ eventsSubscription = null;
292
+ }
293
+
294
+ NativeSDK.unsubscribeFromEvent();
295
+ }
296
+
297
+ //Android-only behavior
298
+
299
+ // ---------------- Push payload bridge ----------------
300
+
301
+ /**
302
+ * Forwards a push payload to native SDK (Android-only behavior).
303
+ *
304
+ * @param message Push payload map (string-only).
305
+ */
306
+ export function takePush(message: Record<string, string>): void {
307
+ if (!message || Object.keys(message).length === 0) return;
308
+ NativeSDK.takePush({ ...message });
309
+ }
310
+
311
+ /**
312
+ * Requests notification permission (Android-only behavior).
313
+ * On Android it may trigger runtime permission flow,
314
+ * n iOS it can be a no-op or routed to native implementation.
315
+ */
316
+ export function requestNotificationPermission(): void {
317
+ return NativeSDK.requestNotificationPermission();
318
+ }
319
+
320
+ // ---------------- Manual push events ----------------
321
+
322
+ /**
323
+ * Reports an Altcraft push delivery event (Android-only behavior).
324
+ *
325
+ * @param message Optional push payload (string-only).
326
+ * @param messageUID Optional Altcraft message UID.
327
+ */
397
328
  export function deliveryEvent(
398
329
  message: Record<string, string> | null = null,
399
330
  messageUID: string | null = null
@@ -401,12 +332,17 @@ export function deliveryEvent(
401
332
  const nativePayload =
402
333
  message && Object.keys(message).length > 0 ? { ...message } : null;
403
334
 
404
- // Kept as runtime call for backward-compat if some platform exposes it outside codegen.
405
- (NativeSDK as unknown as { deliveryEvent: (m: Record<string, string> | null, uid: string | null) => void })
406
- .deliveryEvent(nativePayload, messageUID);
335
+ (NativeSDK as unknown as {
336
+ deliveryEvent: (m: Record<string, string> | null, uid: string | null) => void;
337
+ }).deliveryEvent(nativePayload, messageUID);
407
338
  }
408
339
 
409
- /** Manually records a push open event (fire-and-forget). */
340
+ /**
341
+ * Reports an Altcraft push open event (Android-only behavior).
342
+ *
343
+ * @param message Optional push payload (string-only).
344
+ * @param messageUID Optional Altcraft message UID.
345
+ */
410
346
  export function openEvent(
411
347
  message: Record<string, string> | null = null,
412
348
  messageUID: string | null = null
@@ -414,59 +350,93 @@ export function openEvent(
414
350
  const nativePayload =
415
351
  message && Object.keys(message).length > 0 ? { ...message } : null;
416
352
 
417
- // Kept as runtime call for backward-compat if some platform exposes it outside codegen.
418
- (NativeSDK as unknown as { openEvent: (m: Record<string, string> | null, uid: string | null) => void })
419
- .openEvent(nativePayload, messageUID);
353
+ (NativeSDK as unknown as {
354
+ openEvent: (m: Record<string, string> | null, uid: string | null) => void;
355
+ }).openEvent(nativePayload, messageUID);
356
+ }
357
+
358
+ // ---------------- UserDefaults ----------------
359
+ /**
360
+ * Stores a value into native UserDefaults (IOS-only behavior).
361
+ *
362
+ * @param suiteName iOS App Group suite name or `null` to use standard UserDefaults.
363
+ * @param key Storage key.
364
+ * @param value Any JS value; will be converted to string or removed when `null/undefined`.
365
+ */
366
+ export function setUserDefaultsValue(
367
+ suiteName: string | null,
368
+ key: string,
369
+ value: unknown
370
+ ): void {
371
+ const str = Utilities.toUserDefaultsString(value);
372
+ return NativeSDK.setUserDefaultsValue(suiteName, key, str);
420
373
  }
421
374
 
422
375
  // ---------------- Default export ----------------
423
376
 
424
- /** Public React Native facade for the Altcraft SDK. */
377
+ /**
378
+ * Public React Native facade for the Altcraft SDK.
379
+ *
380
+ * Provides:
381
+ * - SDK initialization
382
+ * - Push subscription operations
383
+ * - Subscription status queries
384
+ * - SDK event stream via NativeEventEmitter
385
+ * - Mobile events
386
+ * - Push token access
387
+ * - Local storage bridge (UserDefaults/SharedPreferences)
388
+ */
425
389
  const AltcraftSDK = {
390
+ // SDK initialization
426
391
  initialize,
427
- setJwt,
428
392
 
393
+ // Push subscription
429
394
  pushSubscribe,
430
395
  pushSuspend,
431
396
  pushUnSubscribe,
432
397
  unSuspendPushSubscription,
398
+
399
+ // Profile status
433
400
  getStatusOfLatestSubscription,
434
401
  getStatusOfLatestSubscriptionForProvider,
435
402
  getStatusForCurrentSubscription,
436
403
 
437
- getPushToken,
438
- deleteDeviceToken,
439
- forcedTokenUpdate,
440
- changePushProviderPriorityList,
441
- setPushToken,
442
-
404
+ // SDK events
405
+ subscribeToEvents,
406
+ unsubscribeFromEvent,
443
407
 
408
+ // Mobile events
444
409
  mobileEvent,
445
410
 
446
- subscribeToEvents,
447
- unsubscribeFromEvent,
411
+ // Push token
412
+ setPushToken,
413
+ getPushToken,
448
414
 
415
+ // Clear SDK data
449
416
  clear,
450
417
 
451
- //ios only
452
- setIosFcmToken,
453
- setIosHmsToken,
454
- setApnsToken,
418
+ // Set UserDefault / SharedPreferenses
455
419
  setUserDefaultsValue,
456
420
 
457
- //android only
458
- setAndroidFcmToken,
459
- setAndroidHmsToken,
460
- setRustoreToken,
461
- PushReceiver,
462
- registerPushReceiver,
463
- clearPushReceivers,
421
+ // Android only
464
422
  takePush,
465
423
  deliveryEvent,
466
424
  openEvent,
467
- unlockInitOperationsInThisSession,
468
425
  requestNotificationPermission,
469
-
470
426
  };
471
427
 
472
428
  export default AltcraftSDK;
429
+
430
+ export type {
431
+ AltcraftConfig,
432
+ CategoryData,
433
+ ResponseWithHttpCode,
434
+ TokenData,
435
+ EmailSubscription,
436
+ SmsSubscription,
437
+ PushSubscription,
438
+ CcDataSubscription,
439
+ Subscription,
440
+ UTM,
441
+ SdkEvent,
442
+ };