@altcraft/react-native-sdk 0.0.4 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +48 -20
- package/README.md +21 -120
- package/autolink.js +36 -0
- package/lib/commonjs/altcraft_sdk.js +297 -0
- package/lib/commonjs/altcraft_sdk.js.map +1 -0
- package/lib/commonjs/index.js +192 -0
- package/lib/commonjs/index.js.map +1 -0
- package/lib/commonjs/package.json +1 -0
- package/lib/module/altcraft_sdk.js +292 -0
- package/lib/module/altcraft_sdk.js.map +1 -0
- package/lib/module/index.js +13 -427
- package/lib/module/index.js.map +1 -1
- package/lib/typescript/commonjs/package.json +1 -0
- package/lib/typescript/commonjs/src/altcraft_sdk.d.ts +143 -0
- package/lib/typescript/commonjs/src/altcraft_sdk.d.ts.map +1 -0
- package/lib/typescript/commonjs/src/index.d.ts +24 -0
- package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
- package/lib/typescript/module/src/altcraft_sdk.d.ts +143 -0
- package/lib/typescript/module/src/altcraft_sdk.d.ts.map +1 -0
- package/lib/typescript/module/src/index.d.ts +24 -0
- package/lib/typescript/module/src/index.d.ts.map +1 -0
- package/package.json +49 -95
- package/scripts/postinstall.cjs +195 -0
- package/src/altcraft_sdk.ts +337 -0
- package/src/index.ts +91 -0
- package/Sdk.podspec +0 -48
- package/android/build.gradle +0 -77
- package/android/gradle.properties +0 -5
- package/android/src/main/AndroidManifest.xml +0 -2
- package/android/src/main/java/com/altcraft/sdk/SdkEventEmitter.kt +0 -50
- package/android/src/main/java/com/altcraft/sdk/SdkModule.kt +0 -949
- package/android/src/main/java/com/altcraft/sdk/SdkPackage.kt +0 -41
- package/android/src/main/java/com/altcraft/sdk/utilities/Converter.kt +0 -326
- package/android/src/main/java/com/altcraft/sdk/utilities/Extension.kt +0 -72
- package/ios/Converter.swift +0 -640
- package/ios/Sdk.h +0 -20
- package/ios/Sdk.mm +0 -979
- package/ios/SdkModule.swift +0 -778
- package/lib/module/NativeSdk.js +0 -48
- package/lib/module/NativeSdk.js.map +0 -1
- package/lib/module/Utilities.js +0 -178
- package/lib/module/Utilities.js.map +0 -1
- package/lib/typescript/src/NativeSdk.d.ts +0 -215
- package/lib/typescript/src/NativeSdk.d.ts.map +0 -1
- package/lib/typescript/src/Utilities.d.ts +0 -47
- package/lib/typescript/src/Utilities.d.ts.map +0 -1
- package/lib/typescript/src/index.d.ts +0 -252
- package/lib/typescript/src/index.d.ts.map +0 -1
- package/react-native.config.js +0 -10
- package/src/NativeSdk.ts +0 -313
- package/src/Utilities.ts +0 -180
- package/src/index.tsx +0 -570
- /package/lib/typescript/{package.json → module/package.json} +0 -0
package/src/index.tsx
DELETED
|
@@ -1,570 +0,0 @@
|
|
|
1
|
-
import { NativeEventEmitter, NativeModules } from 'react-native';
|
|
2
|
-
|
|
3
|
-
import NativeSDK, {
|
|
4
|
-
type AltcraftConfig,
|
|
5
|
-
type CategoryData,
|
|
6
|
-
type ResponseWithHttpCode,
|
|
7
|
-
type TokenData,
|
|
8
|
-
type EmailSubscription,
|
|
9
|
-
type SmsSubscription,
|
|
10
|
-
type PushSubscription,
|
|
11
|
-
type CcDataSubscription,
|
|
12
|
-
type Subscription,
|
|
13
|
-
type UTM,
|
|
14
|
-
type SdkEvent,
|
|
15
|
-
} from './NativeSdk';
|
|
16
|
-
|
|
17
|
-
import { Utilities, ActionFieldBuilder, actionField } from './Utilities';
|
|
18
|
-
|
|
19
|
-
// ---------------- SDK API ----------------
|
|
20
|
-
|
|
21
|
-
/**
|
|
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.
|
|
28
|
-
*/
|
|
29
|
-
export function initialize(config: AltcraftConfig): Promise<void> {
|
|
30
|
-
return NativeSDK.initialize(config);
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
// ---------------- Push subscription ----------------
|
|
34
|
-
|
|
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
|
-
*/
|
|
50
|
-
export function pushSubscribe(
|
|
51
|
-
sync: boolean | null = true,
|
|
52
|
-
profileFields: Record<string, unknown> | null = null,
|
|
53
|
-
customFields: Record<string, unknown> | null = null,
|
|
54
|
-
cats: CategoryData[] | null = null,
|
|
55
|
-
replace: boolean | null = null,
|
|
56
|
-
skipTriggers: boolean | null = null
|
|
57
|
-
): void {
|
|
58
|
-
NativeSDK.pushSubscribe(
|
|
59
|
-
sync,
|
|
60
|
-
Utilities.toNativeStringMap(profileFields),
|
|
61
|
-
Utilities.toNativeStringMap(customFields),
|
|
62
|
-
cats,
|
|
63
|
-
replace,
|
|
64
|
-
skipTriggers
|
|
65
|
-
);
|
|
66
|
-
}
|
|
67
|
-
|
|
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
|
-
*/
|
|
78
|
-
export function pushSuspend(
|
|
79
|
-
sync: boolean | null = true,
|
|
80
|
-
profileFields: Record<string, unknown> | null = null,
|
|
81
|
-
customFields: Record<string, unknown> | null = null,
|
|
82
|
-
cats: CategoryData[] | null = null,
|
|
83
|
-
replace: boolean | null = null,
|
|
84
|
-
skipTriggers: boolean | null = null
|
|
85
|
-
): void {
|
|
86
|
-
NativeSDK.pushSuspend(
|
|
87
|
-
sync,
|
|
88
|
-
Utilities.toNativeStringMap(profileFields),
|
|
89
|
-
Utilities.toNativeStringMap(customFields),
|
|
90
|
-
cats,
|
|
91
|
-
replace,
|
|
92
|
-
skipTriggers
|
|
93
|
-
);
|
|
94
|
-
}
|
|
95
|
-
|
|
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
|
-
*/
|
|
106
|
-
export function pushUnSubscribe(
|
|
107
|
-
sync: boolean | null = true,
|
|
108
|
-
profileFields: Record<string, unknown> | null = null,
|
|
109
|
-
customFields: Record<string, unknown> | null = null,
|
|
110
|
-
cats: CategoryData[] | null = null,
|
|
111
|
-
replace: boolean | null = null,
|
|
112
|
-
skipTriggers: boolean | null = null
|
|
113
|
-
): void {
|
|
114
|
-
NativeSDK.pushUnSubscribe(
|
|
115
|
-
sync,
|
|
116
|
-
Utilities.toNativeStringMap(profileFields),
|
|
117
|
-
Utilities.toNativeStringMap(customFields),
|
|
118
|
-
cats,
|
|
119
|
-
replace,
|
|
120
|
-
skipTriggers
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
|
|
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
|
-
*/
|
|
131
|
-
export function unSuspendPushSubscription(): Promise<ResponseWithHttpCode | null> {
|
|
132
|
-
return NativeSDK.unSuspendPushSubscription();
|
|
133
|
-
}
|
|
134
|
-
|
|
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
|
-
*/
|
|
140
|
-
export function getStatusOfLatestSubscription(): Promise<ResponseWithHttpCode | null> {
|
|
141
|
-
return NativeSDK.getStatusOfLatestSubscription();
|
|
142
|
-
}
|
|
143
|
-
|
|
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
|
-
*/
|
|
161
|
-
export function getStatusOfLatestSubscriptionForProvider(
|
|
162
|
-
provider: string | null = null
|
|
163
|
-
): Promise<ResponseWithHttpCode | null> {
|
|
164
|
-
return NativeSDK.getStatusOfLatestSubscriptionForProvider(provider);
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
// ---------------- Token API ----------------
|
|
168
|
-
|
|
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
|
-
*/
|
|
174
|
-
export function getPushToken(): Promise<TokenData | null> {
|
|
175
|
-
return NativeSDK.getPushToken();
|
|
176
|
-
}
|
|
177
|
-
|
|
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
|
-
*/
|
|
185
|
-
export function setPushToken(
|
|
186
|
-
provider: string,
|
|
187
|
-
token: string | null
|
|
188
|
-
): Promise<void> {
|
|
189
|
-
return NativeSDK.setPushToken(provider, token);
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
// ---------------- SDK wrappers ----------------
|
|
193
|
-
|
|
194
|
-
/**
|
|
195
|
-
* Clears SDK local state (native).
|
|
196
|
-
*
|
|
197
|
-
* @returns Promise that resolves after cleanup.
|
|
198
|
-
*/
|
|
199
|
-
export function clear(): Promise<void> {
|
|
200
|
-
return NativeSDK.clear();
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// ---------------- MobileEvent ----------------
|
|
204
|
-
|
|
205
|
-
/**
|
|
206
|
-
* Sends a mobile event to the server.
|
|
207
|
-
*
|
|
208
|
-
* @param sid Pixel identifier.
|
|
209
|
-
* @param eventName Event name.
|
|
210
|
-
* @param sendMessageId Optional message identifier to link the event.
|
|
211
|
-
* @param payload Optional event payload.
|
|
212
|
-
* @param matching Optional matching parameters.
|
|
213
|
-
* @param matchingType Optional matching mode/type.
|
|
214
|
-
* @param profileFields Optional profile fields.
|
|
215
|
-
* @param subscription Optional subscription info to attach (email/sms/push/cc_data).
|
|
216
|
-
* @param utm Optional UTM tags for attribution.
|
|
217
|
-
*/
|
|
218
|
-
export function mobileEvent(
|
|
219
|
-
sid: string,
|
|
220
|
-
eventName: string,
|
|
221
|
-
sendMessageId: string | null = null,
|
|
222
|
-
payload: Record<string, unknown> | null = null,
|
|
223
|
-
matching: Record<string, unknown> | null = null,
|
|
224
|
-
matchingType: string | null = null,
|
|
225
|
-
profileFields: Record<string, unknown> | null = null,
|
|
226
|
-
subscription: Subscription | null = null,
|
|
227
|
-
utm: UTM | null = null
|
|
228
|
-
): void {
|
|
229
|
-
NativeSDK.mobileEvent(
|
|
230
|
-
sid,
|
|
231
|
-
eventName,
|
|
232
|
-
sendMessageId,
|
|
233
|
-
Utilities.toNativeStringMap(payload),
|
|
234
|
-
Utilities.toNativeStringMap(matching),
|
|
235
|
-
matchingType,
|
|
236
|
-
Utilities.toNativeStringMap(profileFields),
|
|
237
|
-
Utilities.subscriptionToNativeMap(subscription),
|
|
238
|
-
utm ?? { campaign: null, content: null, keyword: null, medium: null, source: null, temp: null }
|
|
239
|
-
);
|
|
240
|
-
}
|
|
241
|
-
|
|
242
|
-
// ---------------- SDK Event API ----------------
|
|
243
|
-
|
|
244
|
-
type EventsSubscription = { remove: () => void } | null;
|
|
245
|
-
const ALTCRAFT_SDK_EVENT_NAME = 'AltcraftSdkEvent' as const;
|
|
246
|
-
const nativeEventEmitter = new NativeEventEmitter(
|
|
247
|
-
NativeModules.SDKEventEmitter
|
|
248
|
-
);
|
|
249
|
-
|
|
250
|
-
let eventsSubscription: EventsSubscription = null;
|
|
251
|
-
const eventHandlers = new Set<(event: SdkEvent) => void>();
|
|
252
|
-
|
|
253
|
-
function ensureNativeSubscription(): void {
|
|
254
|
-
if (eventsSubscription === null) {
|
|
255
|
-
NativeSDK.subscribeToEvents();
|
|
256
|
-
eventsSubscription = nativeEventEmitter.addListener(
|
|
257
|
-
ALTCRAFT_SDK_EVENT_NAME,
|
|
258
|
-
(...args: unknown[]) => {
|
|
259
|
-
const event = (args[0] ?? null) as SdkEvent | null;
|
|
260
|
-
if (!event) return;
|
|
261
|
-
|
|
262
|
-
const handlers = Array.from(eventHandlers);
|
|
263
|
-
for (const handler of handlers) {
|
|
264
|
-
try {
|
|
265
|
-
handler(event);
|
|
266
|
-
} catch (e) {
|
|
267
|
-
console.warn('[AltcraftSDK] subscribeToEvents handler error:', e);
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
}
|
|
271
|
-
);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* Subscribes to native SDK events and routes them to the provided handler.
|
|
277
|
-
*
|
|
278
|
-
* Multiple callers can subscribe independently — each handler receives every event.
|
|
279
|
-
* The native subscription is activated only once (first caller).
|
|
280
|
-
*
|
|
281
|
-
* @param handler Callback invoked for each incoming SDK event.
|
|
282
|
-
* The event object is produced by native and follows {@link SdkEvent}.
|
|
283
|
-
*/
|
|
284
|
-
export function subscribeToEvents(handler: (event: SdkEvent) => void): void {
|
|
285
|
-
eventHandlers.add(handler);
|
|
286
|
-
ensureNativeSubscription();
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
/**
|
|
290
|
-
* Unsubscribes a specific handler from native SDK events.
|
|
291
|
-
*
|
|
292
|
-
* When the last handler is removed, the native subscription is also released.
|
|
293
|
-
* Safe to call even if not subscribed.
|
|
294
|
-
*/
|
|
295
|
-
export function unsubscribeFromEvent(
|
|
296
|
-
handler?: (event: SdkEvent) => void
|
|
297
|
-
): void {
|
|
298
|
-
if (handler) {
|
|
299
|
-
eventHandlers.delete(handler);
|
|
300
|
-
}
|
|
301
|
-
|
|
302
|
-
if (eventHandlers.size === 0) {
|
|
303
|
-
if (eventsSubscription) {
|
|
304
|
-
eventsSubscription.remove();
|
|
305
|
-
eventsSubscription = null;
|
|
306
|
-
}
|
|
307
|
-
NativeSDK.unsubscribeFromEvent();
|
|
308
|
-
}
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
//Android-only behavior
|
|
312
|
-
|
|
313
|
-
// ---------------- Push payload bridge ----------------
|
|
314
|
-
|
|
315
|
-
/**
|
|
316
|
-
* Forwards a push payload to native SDK (Android-only behavior).
|
|
317
|
-
*
|
|
318
|
-
* @param message Push payload map (string-only).
|
|
319
|
-
*/
|
|
320
|
-
export function takePush(message: Record<string, string>): void {
|
|
321
|
-
if (!message || Object.keys(message).length === 0) return;
|
|
322
|
-
NativeSDK.takePush({ ...message });
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
/**
|
|
326
|
-
* Requests notification permission (Android-only behavior).
|
|
327
|
-
* On Android it may trigger runtime permission flow,
|
|
328
|
-
* n iOS it can be a no-op or routed to native implementation.
|
|
329
|
-
*/
|
|
330
|
-
export function requestNotificationPermission(): void {
|
|
331
|
-
return NativeSDK.requestNotificationPermission();
|
|
332
|
-
}
|
|
333
|
-
|
|
334
|
-
// ---------------- Manual push events ----------------
|
|
335
|
-
|
|
336
|
-
/**
|
|
337
|
-
* Reports an Altcraft push delivery event (Android-only behavior).
|
|
338
|
-
*
|
|
339
|
-
* @param message Optional push payload (string-only).
|
|
340
|
-
* @param messageUID Optional Altcraft message UID.
|
|
341
|
-
*/
|
|
342
|
-
export function deliveryEvent(
|
|
343
|
-
message: Record<string, string> | null = null,
|
|
344
|
-
messageUID: string | null = null
|
|
345
|
-
): void {
|
|
346
|
-
const nativePayload =
|
|
347
|
-
message && Object.keys(message).length > 0 ? { ...message } : null;
|
|
348
|
-
|
|
349
|
-
(
|
|
350
|
-
NativeSDK as unknown as {
|
|
351
|
-
deliveryEvent: (
|
|
352
|
-
m: Record<string, string> | null,
|
|
353
|
-
uid: string | null
|
|
354
|
-
) => void;
|
|
355
|
-
}
|
|
356
|
-
).deliveryEvent(nativePayload, messageUID);
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
/**
|
|
360
|
-
* Reports an Altcraft push open event (Android-only behavior).
|
|
361
|
-
*
|
|
362
|
-
* @param message Optional push payload (string-only).
|
|
363
|
-
* @param messageUID Optional Altcraft message UID.
|
|
364
|
-
*/
|
|
365
|
-
export function openEvent(
|
|
366
|
-
message: Record<string, string> | null = null,
|
|
367
|
-
messageUID: string | null = null
|
|
368
|
-
): void {
|
|
369
|
-
const nativePayload =
|
|
370
|
-
message && Object.keys(message).length > 0 ? { ...message } : null;
|
|
371
|
-
|
|
372
|
-
(
|
|
373
|
-
NativeSDK as unknown as {
|
|
374
|
-
openEvent: (m: Record<string, string> | null, uid: string | null) => void;
|
|
375
|
-
}
|
|
376
|
-
).openEvent(nativePayload, messageUID);
|
|
377
|
-
}
|
|
378
|
-
|
|
379
|
-
// ---------------- UserDefaults ----------------
|
|
380
|
-
/**
|
|
381
|
-
* Stores a value into native UserDefaults (IOS-only behavior).
|
|
382
|
-
*
|
|
383
|
-
* @param suiteName iOS App Group suite name or `null` to use standard UserDefaults.
|
|
384
|
-
* @param key Storage key.
|
|
385
|
-
* @param value Any JS value; will be converted to string or removed when `null/undefined`.
|
|
386
|
-
*/
|
|
387
|
-
export function setUserDefaultsValue(
|
|
388
|
-
suiteName: string | null,
|
|
389
|
-
key: string,
|
|
390
|
-
value: unknown
|
|
391
|
-
): void {
|
|
392
|
-
const str = Utilities.toUserDefaultsString(value);
|
|
393
|
-
return NativeSDK.setUserDefaultsValue(suiteName, key, str);
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
// ---------------- Profile API ----------------
|
|
397
|
-
|
|
398
|
-
/**
|
|
399
|
-
* Updates profile fields on the server.
|
|
400
|
-
*
|
|
401
|
-
* @param profileFields Optional profile fields to update.
|
|
402
|
-
* @param skipTriggers Optional flag to skip trigger execution on the server.
|
|
403
|
-
*/
|
|
404
|
-
export function updateProfileFields(
|
|
405
|
-
profileFields: Record<string, unknown> | null = null,
|
|
406
|
-
skipTriggers: boolean | null = null
|
|
407
|
-
): void {
|
|
408
|
-
NativeSDK.updateProfileFields(
|
|
409
|
-
Utilities.toNativeStringMap(profileFields),
|
|
410
|
-
skipTriggers
|
|
411
|
-
);
|
|
412
|
-
}
|
|
413
|
-
|
|
414
|
-
// ---------------- Token management API ----------------
|
|
415
|
-
|
|
416
|
-
/**
|
|
417
|
-
* Forces a push token refresh (delete current token + re-register).
|
|
418
|
-
*
|
|
419
|
-
* @returns Promise that resolves when the token update flow completes.
|
|
420
|
-
*/
|
|
421
|
-
export function forcedTokenUpdate(): Promise<void> {
|
|
422
|
-
return NativeSDK.forcedTokenUpdate();
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
/**
|
|
426
|
-
* Deletes the device token for a given provider.
|
|
427
|
-
*
|
|
428
|
-
* @param provider Provider identifier (e.g. `android-firebase`, `ios-firebase`).
|
|
429
|
-
* @returns Promise that resolves when the delete call completes.
|
|
430
|
-
*/
|
|
431
|
-
export function deleteDeviceToken(provider: string): Promise<void> {
|
|
432
|
-
return NativeSDK.deleteDeviceToken(provider);
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
/**
|
|
436
|
-
* Changes the push provider priority list at runtime.
|
|
437
|
-
*
|
|
438
|
-
* @param priorityList Ordered list of provider identifiers.
|
|
439
|
-
* @returns Promise that resolves when the priority list is updated.
|
|
440
|
-
*/
|
|
441
|
-
export function changePushProviderPriorityList(
|
|
442
|
-
priorityList: string[] | null
|
|
443
|
-
): Promise<void> {
|
|
444
|
-
if (!priorityList || priorityList.length === 0) {
|
|
445
|
-
return Promise.resolve();
|
|
446
|
-
}
|
|
447
|
-
return NativeSDK.changePushProviderPriorityList(priorityList);
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
// ---------------- PushReceiver helpers ----------------
|
|
451
|
-
|
|
452
|
-
/**
|
|
453
|
-
* Checks whether a push payload belongs to Altcraft.
|
|
454
|
-
*
|
|
455
|
-
* @param message Push payload map (string-only).
|
|
456
|
-
* @returns `true` if the message contains the Altcraft marker key.
|
|
457
|
-
*/
|
|
458
|
-
export function isAltcraftPush(message: Record<string, string>): boolean {
|
|
459
|
-
if (!message || Object.keys(message).length === 0) return false;
|
|
460
|
-
return NativeSDK.isAltcraftPush({ ...message });
|
|
461
|
-
}
|
|
462
|
-
|
|
463
|
-
// ---------------- SDK lifecycle ----------------
|
|
464
|
-
|
|
465
|
-
/**
|
|
466
|
-
* Allows re-running initial retry/scheduling/token-check logic
|
|
467
|
-
* in this process on the next initialization (Android only).
|
|
468
|
-
* No-op on iOS.
|
|
469
|
-
*/
|
|
470
|
-
export function unlockInitialOperationsInThisSession(): void {
|
|
471
|
-
NativeSDK.unlockInitialOperationsInThisSession();
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
// ---------------- iOS-only ----------------
|
|
475
|
-
|
|
476
|
-
/**
|
|
477
|
-
* Sets the App Group name for shared UserDefaults and Core Data (iOS only).
|
|
478
|
-
* Must be called before SDK initialization.
|
|
479
|
-
*
|
|
480
|
-
* @param groupName App Group identifier or `null` to clear.
|
|
481
|
-
*/
|
|
482
|
-
export function setAppGroup(groupName: string | null): void {
|
|
483
|
-
NativeSDK.setAppGroup(groupName);
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
// ---------------- Default export ----------------
|
|
487
|
-
|
|
488
|
-
/**
|
|
489
|
-
* Public React Native facade for the Altcraft SDK.
|
|
490
|
-
*
|
|
491
|
-
* Provides:
|
|
492
|
-
* - SDK initialization
|
|
493
|
-
* - Push subscription operations
|
|
494
|
-
* - Subscription status queries
|
|
495
|
-
* - SDK event stream via NativeEventEmitter
|
|
496
|
-
* - Mobile events
|
|
497
|
-
* - Push token access
|
|
498
|
-
* - Local storage bridge (UserDefaults/SharedPreferences)
|
|
499
|
-
*/
|
|
500
|
-
const AltcraftSDK = {
|
|
501
|
-
// SDK initialization
|
|
502
|
-
initialize,
|
|
503
|
-
|
|
504
|
-
// Push subscription
|
|
505
|
-
pushSubscribe,
|
|
506
|
-
pushSuspend,
|
|
507
|
-
pushUnSubscribe,
|
|
508
|
-
unSuspendPushSubscription,
|
|
509
|
-
|
|
510
|
-
// Profile status
|
|
511
|
-
getStatusOfLatestSubscription,
|
|
512
|
-
getStatusOfLatestSubscriptionForProvider,
|
|
513
|
-
getStatusForCurrentSubscription,
|
|
514
|
-
|
|
515
|
-
// SDK events
|
|
516
|
-
subscribeToEvents,
|
|
517
|
-
unsubscribeFromEvent,
|
|
518
|
-
|
|
519
|
-
// Mobile events
|
|
520
|
-
mobileEvent,
|
|
521
|
-
|
|
522
|
-
// Push token
|
|
523
|
-
setPushToken,
|
|
524
|
-
getPushToken,
|
|
525
|
-
|
|
526
|
-
// Clear SDK data
|
|
527
|
-
clear,
|
|
528
|
-
|
|
529
|
-
// Set UserDefault / SharedPreferenses
|
|
530
|
-
setUserDefaultsValue,
|
|
531
|
-
|
|
532
|
-
// Android only
|
|
533
|
-
takePush,
|
|
534
|
-
deliveryEvent,
|
|
535
|
-
openEvent,
|
|
536
|
-
requestNotificationPermission,
|
|
537
|
-
unlockInitialOperationsInThisSession,
|
|
538
|
-
|
|
539
|
-
// Profile API
|
|
540
|
-
updateProfileFields,
|
|
541
|
-
|
|
542
|
-
// Token management
|
|
543
|
-
forcedTokenUpdate,
|
|
544
|
-
deleteDeviceToken,
|
|
545
|
-
changePushProviderPriorityList,
|
|
546
|
-
|
|
547
|
-
// PushReceiver helpers
|
|
548
|
-
isAltcraftPush,
|
|
549
|
-
|
|
550
|
-
// iOS only
|
|
551
|
-
setAppGroup,
|
|
552
|
-
};
|
|
553
|
-
|
|
554
|
-
export default AltcraftSDK;
|
|
555
|
-
|
|
556
|
-
export { ActionFieldBuilder, actionField };
|
|
557
|
-
|
|
558
|
-
export type {
|
|
559
|
-
AltcraftConfig,
|
|
560
|
-
CategoryData,
|
|
561
|
-
ResponseWithHttpCode,
|
|
562
|
-
TokenData,
|
|
563
|
-
EmailSubscription,
|
|
564
|
-
SmsSubscription,
|
|
565
|
-
PushSubscription,
|
|
566
|
-
CcDataSubscription,
|
|
567
|
-
Subscription,
|
|
568
|
-
UTM,
|
|
569
|
-
SdkEvent,
|
|
570
|
-
};
|
|
File without changes
|