@altcraft/react-native-sdk 0.0.5 → 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.
Files changed (52) hide show
  1. package/README.md +21 -120
  2. package/autolink.js +36 -0
  3. package/lib/commonjs/altcraft_sdk.js +297 -0
  4. package/lib/commonjs/altcraft_sdk.js.map +1 -0
  5. package/lib/commonjs/index.js +192 -0
  6. package/lib/commonjs/index.js.map +1 -0
  7. package/lib/commonjs/package.json +1 -0
  8. package/lib/module/altcraft_sdk.js +292 -0
  9. package/lib/module/altcraft_sdk.js.map +1 -0
  10. package/lib/module/index.js +13 -427
  11. package/lib/module/index.js.map +1 -1
  12. package/lib/typescript/commonjs/package.json +1 -0
  13. package/lib/typescript/commonjs/src/altcraft_sdk.d.ts +143 -0
  14. package/lib/typescript/commonjs/src/altcraft_sdk.d.ts.map +1 -0
  15. package/lib/typescript/commonjs/src/index.d.ts +24 -0
  16. package/lib/typescript/commonjs/src/index.d.ts.map +1 -0
  17. package/lib/typescript/module/src/altcraft_sdk.d.ts +143 -0
  18. package/lib/typescript/module/src/altcraft_sdk.d.ts.map +1 -0
  19. package/lib/typescript/module/src/index.d.ts +24 -0
  20. package/lib/typescript/module/src/index.d.ts.map +1 -0
  21. package/package.json +49 -95
  22. package/scripts/postinstall.cjs +195 -0
  23. package/src/altcraft_sdk.ts +337 -0
  24. package/src/index.ts +91 -0
  25. package/Sdk.podspec +0 -48
  26. package/android/build.gradle +0 -77
  27. package/android/gradle.properties +0 -5
  28. package/android/src/main/AndroidManifest.xml +0 -2
  29. package/android/src/main/java/com/altcraft/sdk/SdkEventEmitter.kt +0 -55
  30. package/android/src/main/java/com/altcraft/sdk/SdkModule.kt +0 -993
  31. package/android/src/main/java/com/altcraft/sdk/SdkPackage.kt +0 -41
  32. package/android/src/main/java/com/altcraft/sdk/utilities/Converter.kt +0 -326
  33. package/android/src/main/java/com/altcraft/sdk/utilities/Extension.kt +0 -72
  34. package/ios/Converter.swift +0 -640
  35. package/ios/Sdk.h +0 -20
  36. package/ios/Sdk.mm +0 -979
  37. package/ios/SdkModule.swift +0 -778
  38. package/lib/module/NativeSdk.js +0 -48
  39. package/lib/module/NativeSdk.js.map +0 -1
  40. package/lib/module/Utilities.js +0 -178
  41. package/lib/module/Utilities.js.map +0 -1
  42. package/lib/typescript/src/NativeSdk.d.ts +0 -215
  43. package/lib/typescript/src/NativeSdk.d.ts.map +0 -1
  44. package/lib/typescript/src/Utilities.d.ts +0 -47
  45. package/lib/typescript/src/Utilities.d.ts.map +0 -1
  46. package/lib/typescript/src/index.d.ts +0 -252
  47. package/lib/typescript/src/index.d.ts.map +0 -1
  48. package/react-native.config.js +0 -10
  49. package/src/NativeSdk.ts +0 -313
  50. package/src/Utilities.ts +0 -180
  51. package/src/index.tsx +0 -570
  52. /package/lib/typescript/{package.json → module/package.json} +0 -0
@@ -1,252 +0,0 @@
1
- import { type AltcraftConfig, type CategoryData, type ResponseWithHttpCode, type TokenData, type EmailSubscription, type SmsSubscription, type PushSubscription, type CcDataSubscription, type Subscription, type UTM, type SdkEvent } from './NativeSdk';
2
- import { ActionFieldBuilder, actionField } from './Utilities';
3
- /**
4
- * Initializes the Altcraft SDK.
5
- *
6
- * @param config SDK configuration.
7
- * `apiUrl` is required.
8
- * Other fields are optional and depend on platform features.
9
- * @returns Promise that resolves on successful initialization.
10
- */
11
- export declare function initialize(config: AltcraftConfig): Promise<void>;
12
- /**
13
- * Sends a push subscribe request.
14
- *
15
- * @param sync Execution mode:
16
- * `true` — sends a synchronous request to the server and returns
17
- * the result of the operation execution.
18
- * `false` — sends an asynchronous request and returns
19
- * the result of task enqueueing on the server.
20
- * `null` — native default behavior.
21
- * @param profileFields Optional profile fields to attach to the request.
22
- * @param customFields Optional custom fields to attach to the request.
23
- * @param cats Optional categories list.
24
- * @param replace Optional flag to replace an existing subscription.
25
- * @param skipTriggers Optional flag to skip trigger execution on the server.
26
- */
27
- export declare function pushSubscribe(sync?: boolean | null, profileFields?: Record<string, unknown> | null, customFields?: Record<string, unknown> | null, cats?: CategoryData[] | null, replace?: boolean | null, skipTriggers?: boolean | null): void;
28
- /**
29
- * Sends a push suspend request.
30
- *
31
- * @param sync Execution mode (see {@link pushSubscribe}).
32
- * @param profileFields Optional profile fields.
33
- * @param customFields Optional custom fields.
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 declare function pushSuspend(sync?: boolean | null, profileFields?: Record<string, unknown> | null, customFields?: Record<string, unknown> | null, cats?: CategoryData[] | null, replace?: boolean | null, skipTriggers?: boolean | null): void;
39
- /**
40
- * Sends a push unsubscribe request.
41
- *
42
- * @param sync Execution mode (see {@link pushSubscribe}).
43
- * @param profileFields Optional profile fields.
44
- * @param customFields Optional custom fields.
45
- * @param cats Optional categories list.
46
- * @param replace Optional flag to replace an existing subscription.
47
- * @param skipTriggers Optional flag to skip trigger execution on the server.
48
- */
49
- export declare function pushUnSubscribe(sync?: boolean | null, profileFields?: Record<string, unknown> | null, customFields?: Record<string, unknown> | null, cats?: CategoryData[] | null, replace?: boolean | null, skipTriggers?: boolean | null): void;
50
- /**
51
- * Unsuspends push subscriptions based on native matching rules.
52
- *
53
- * @returns Promise resolving to response with HTTP code or `null` if unavailable.
54
- */
55
- export declare function unSuspendPushSubscription(): Promise<ResponseWithHttpCode | null>;
56
- /**
57
- * Returns the status of the latest subscription in profile.
58
- *
59
- * @returns Promise resolving to response with HTTP code or `null` if unavailable.
60
- */
61
- export declare function getStatusOfLatestSubscription(): Promise<ResponseWithHttpCode | null>;
62
- /**
63
- * Returns the status of the subscription matching the current push token and provider context.
64
- *
65
- * @returns Promise resolving to response with HTTP code or `null` if unavailable.
66
- */
67
- export declare function getStatusForCurrentSubscription(): Promise<ResponseWithHttpCode | null>;
68
- /**
69
- * Returns the status of the latest subscription for the given provider.
70
- *
71
- * If `provider` is `null`, native side may use the current provider context.
72
- *
73
- * @param provider Optional provider identifier (platform-dependent).
74
- * @returns Promise resolving to response with HTTP code or `null` if unavailable.
75
- */
76
- export declare function getStatusOfLatestSubscriptionForProvider(provider?: string | null): Promise<ResponseWithHttpCode | null>;
77
- /**
78
- * Returns the current push token data from native side.
79
- *
80
- * @returns Promise resolving to token info or `null` if token is not available.
81
- */
82
- export declare function getPushToken(): Promise<TokenData | null>;
83
- /**
84
- * Sets or clears the push token for a specific provider.
85
- *
86
- * @param provider Provider identifier (e.g. platform push provider name).
87
- * @param token Token string or `null` to clear.
88
- * @returns Promise that resolves when the token is saved on native side.
89
- */
90
- export declare function setPushToken(provider: string, token: string | null): Promise<void>;
91
- /**
92
- * Clears SDK local state (native).
93
- *
94
- * @returns Promise that resolves after cleanup.
95
- */
96
- export declare function clear(): Promise<void>;
97
- /**
98
- * Sends a mobile event to the server.
99
- *
100
- * @param sid Pixel identifier.
101
- * @param eventName Event name.
102
- * @param sendMessageId Optional message identifier to link the event.
103
- * @param payload Optional event payload.
104
- * @param matching Optional matching parameters.
105
- * @param matchingType Optional matching mode/type.
106
- * @param profileFields Optional profile fields.
107
- * @param subscription Optional subscription info to attach (email/sms/push/cc_data).
108
- * @param utm Optional UTM tags for attribution.
109
- */
110
- export declare function mobileEvent(sid: string, eventName: string, sendMessageId?: string | null, payload?: Record<string, unknown> | null, matching?: Record<string, unknown> | null, matchingType?: string | null, profileFields?: Record<string, unknown> | null, subscription?: Subscription | null, utm?: UTM | null): void;
111
- /**
112
- * Subscribes to native SDK events and routes them to the provided handler.
113
- *
114
- * Multiple callers can subscribe independently — each handler receives every event.
115
- * The native subscription is activated only once (first caller).
116
- *
117
- * @param handler Callback invoked for each incoming SDK event.
118
- * The event object is produced by native and follows {@link SdkEvent}.
119
- */
120
- export declare function subscribeToEvents(handler: (event: SdkEvent) => void): void;
121
- /**
122
- * Unsubscribes a specific handler from native SDK events.
123
- *
124
- * When the last handler is removed, the native subscription is also released.
125
- * Safe to call even if not subscribed.
126
- */
127
- export declare function unsubscribeFromEvent(handler?: (event: SdkEvent) => void): void;
128
- /**
129
- * Forwards a push payload to native SDK (Android-only behavior).
130
- *
131
- * @param message Push payload map (string-only).
132
- */
133
- export declare function takePush(message: Record<string, string>): void;
134
- /**
135
- * Requests notification permission (Android-only behavior).
136
- * On Android it may trigger runtime permission flow,
137
- * n iOS it can be a no-op or routed to native implementation.
138
- */
139
- export declare function requestNotificationPermission(): void;
140
- /**
141
- * Reports an Altcraft push delivery event (Android-only behavior).
142
- *
143
- * @param message Optional push payload (string-only).
144
- * @param messageUID Optional Altcraft message UID.
145
- */
146
- export declare function deliveryEvent(message?: Record<string, string> | null, messageUID?: string | null): void;
147
- /**
148
- * Reports an Altcraft push open event (Android-only behavior).
149
- *
150
- * @param message Optional push payload (string-only).
151
- * @param messageUID Optional Altcraft message UID.
152
- */
153
- export declare function openEvent(message?: Record<string, string> | null, messageUID?: string | null): void;
154
- /**
155
- * Stores a value into native UserDefaults (IOS-only behavior).
156
- *
157
- * @param suiteName iOS App Group suite name or `null` to use standard UserDefaults.
158
- * @param key Storage key.
159
- * @param value Any JS value; will be converted to string or removed when `null/undefined`.
160
- */
161
- export declare function setUserDefaultsValue(suiteName: string | null, key: string, value: unknown): void;
162
- /**
163
- * Updates profile fields on the server.
164
- *
165
- * @param profileFields Optional profile fields to update.
166
- * @param skipTriggers Optional flag to skip trigger execution on the server.
167
- */
168
- export declare function updateProfileFields(profileFields?: Record<string, unknown> | null, skipTriggers?: boolean | null): void;
169
- /**
170
- * Forces a push token refresh (delete current token + re-register).
171
- *
172
- * @returns Promise that resolves when the token update flow completes.
173
- */
174
- export declare function forcedTokenUpdate(): Promise<void>;
175
- /**
176
- * Deletes the device token for a given provider.
177
- *
178
- * @param provider Provider identifier (e.g. `android-firebase`, `ios-firebase`).
179
- * @returns Promise that resolves when the delete call completes.
180
- */
181
- export declare function deleteDeviceToken(provider: string): Promise<void>;
182
- /**
183
- * Changes the push provider priority list at runtime.
184
- *
185
- * @param priorityList Ordered list of provider identifiers.
186
- * @returns Promise that resolves when the priority list is updated.
187
- */
188
- export declare function changePushProviderPriorityList(priorityList: string[] | null): Promise<void>;
189
- /**
190
- * Checks whether a push payload belongs to Altcraft.
191
- *
192
- * @param message Push payload map (string-only).
193
- * @returns `true` if the message contains the Altcraft marker key.
194
- */
195
- export declare function isAltcraftPush(message: Record<string, string>): boolean;
196
- /**
197
- * Allows re-running initial retry/scheduling/token-check logic
198
- * in this process on the next initialization (Android only).
199
- * No-op on iOS.
200
- */
201
- export declare function unlockInitialOperationsInThisSession(): void;
202
- /**
203
- * Sets the App Group name for shared UserDefaults and Core Data (iOS only).
204
- * Must be called before SDK initialization.
205
- *
206
- * @param groupName App Group identifier or `null` to clear.
207
- */
208
- export declare function setAppGroup(groupName: string | null): void;
209
- /**
210
- * Public React Native facade for the Altcraft SDK.
211
- *
212
- * Provides:
213
- * - SDK initialization
214
- * - Push subscription operations
215
- * - Subscription status queries
216
- * - SDK event stream via NativeEventEmitter
217
- * - Mobile events
218
- * - Push token access
219
- * - Local storage bridge (UserDefaults/SharedPreferences)
220
- */
221
- declare const AltcraftSDK: {
222
- initialize: typeof initialize;
223
- pushSubscribe: typeof pushSubscribe;
224
- pushSuspend: typeof pushSuspend;
225
- pushUnSubscribe: typeof pushUnSubscribe;
226
- unSuspendPushSubscription: typeof unSuspendPushSubscription;
227
- getStatusOfLatestSubscription: typeof getStatusOfLatestSubscription;
228
- getStatusOfLatestSubscriptionForProvider: typeof getStatusOfLatestSubscriptionForProvider;
229
- getStatusForCurrentSubscription: typeof getStatusForCurrentSubscription;
230
- subscribeToEvents: typeof subscribeToEvents;
231
- unsubscribeFromEvent: typeof unsubscribeFromEvent;
232
- mobileEvent: typeof mobileEvent;
233
- setPushToken: typeof setPushToken;
234
- getPushToken: typeof getPushToken;
235
- clear: typeof clear;
236
- setUserDefaultsValue: typeof setUserDefaultsValue;
237
- takePush: typeof takePush;
238
- deliveryEvent: typeof deliveryEvent;
239
- openEvent: typeof openEvent;
240
- requestNotificationPermission: typeof requestNotificationPermission;
241
- unlockInitialOperationsInThisSession: typeof unlockInitialOperationsInThisSession;
242
- updateProfileFields: typeof updateProfileFields;
243
- forcedTokenUpdate: typeof forcedTokenUpdate;
244
- deleteDeviceToken: typeof deleteDeviceToken;
245
- changePushProviderPriorityList: typeof changePushProviderPriorityList;
246
- isAltcraftPush: typeof isAltcraftPush;
247
- setAppGroup: typeof setAppGroup;
248
- };
249
- export default AltcraftSDK;
250
- export { ActionFieldBuilder, actionField };
251
- export type { AltcraftConfig, CategoryData, ResponseWithHttpCode, TokenData, EmailSubscription, SmsSubscription, PushSubscription, CcDataSubscription, Subscription, UTM, SdkEvent, };
252
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"AAEA,OAAkB,EAChB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,oBAAoB,EACzB,KAAK,SAAS,EACd,KAAK,iBAAiB,EACtB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,kBAAkB,EACvB,KAAK,YAAY,EACjB,KAAK,GAAG,EACR,KAAK,QAAQ,EACd,MAAM,aAAa,CAAC;AAErB,OAAO,EAAa,kBAAkB,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAIzE;;;;;;;GAOG;AACH,wBAAgB,UAAU,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC,CAEhE;AAID;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,aAAa,CAC3B,IAAI,GAAE,OAAO,GAAG,IAAW,EAC3B,aAAa,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAW,EACpD,YAAY,GAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,IAAW,EACnD,IAAI,GAAE,YAAY,EAAE,GAAG,IAAW,EAClC,OAAO,GAAE,OAAO,GAAG,IAAW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EAChB,kBAAkB,EAClB,YAAY,EACZ,GAAG,EACH,QAAQ,GACT,CAAC"}
@@ -1,10 +0,0 @@
1
- module.exports = {
2
- dependency: {
3
- platforms: {
4
- android: {
5
- packageImportPath: 'import com.altcraft.sdk.SdkPackage;',
6
- packageInstance: 'new SdkPackage()',
7
- },
8
- },
9
- },
10
- };
package/src/NativeSdk.ts DELETED
@@ -1,313 +0,0 @@
1
- import { TurboModuleRegistry, type TurboModule } from 'react-native';
2
-
3
- // ---------------- Data models ----------------
4
-
5
- /** Subscription category metadata. */
6
- export type CategoryData = {
7
- name?: string | null;
8
- title?: string | null;
9
- steady?: boolean | null;
10
- active?: boolean | null;
11
- };
12
-
13
- /** UTM parameters for event attribution. */
14
- export type UTM = {
15
- campaign?: string | null;
16
- content?: string | null;
17
- keyword?: string | null;
18
- medium?: string | null;
19
- source?: string | null;
20
- temp?: string | null;
21
- };
22
-
23
- // ---------------- Subscription Types ----------------
24
-
25
- /** Email subscription data. */
26
- export type EmailSubscription = {
27
- type: 'email';
28
- resource_id: number;
29
- email: string;
30
- status?: string | null;
31
- priority?: number | null;
32
- custom_fields?: { [key: string]: string } | null;
33
- cats?: string[] | null;
34
- };
35
-
36
- /** SMS subscription data. */
37
- export type SmsSubscription = {
38
- type: 'sms';
39
- resource_id: number;
40
- phone: string;
41
- status?: string | null;
42
- priority?: number | null;
43
- custom_fields?: { [key: string]: string } | null;
44
- cats?: string[] | null;
45
- };
46
-
47
- /** Push subscription data. */
48
- export type PushSubscription = {
49
- type: 'push';
50
- resource_id: number;
51
- provider: string;
52
- subscription_id: string;
53
- status?: string | null;
54
- priority?: number | null;
55
- custom_fields?: { [key: string]: string } | null;
56
- cats?: string[] | null;
57
- };
58
-
59
- /** CC-data subscription (Telegram, WhatsApp, Viber, Notify). */
60
- export type CcDataSubscription = {
61
- type: 'cc_data';
62
- resource_id: number;
63
- channel: string; // 'telegram_bot', 'whatsapp', 'viber', 'notify'
64
- cc_data: { [key: string]: string };
65
- status?: string | null;
66
- priority?: number | null;
67
- custom_fields?: { [key: string]: string } | null;
68
- cats?: string[] | null;
69
- };
70
-
71
- /** Union of all supported subscription types. */
72
- export type Subscription =
73
- | EmailSubscription
74
- | SmsSubscription
75
- | PushSubscription
76
- | CcDataSubscription;
77
-
78
- // ---------------- API models ----------------
79
-
80
- /** Profile data returned from the API. */
81
- export type ProfileData = {
82
- id?: string | null;
83
- status?: string | null;
84
- isTest?: boolean | null;
85
- subscription?: Subscription | null;
86
- };
87
-
88
- /** API response payload. */
89
- export type Response = {
90
- error?: number | null;
91
- errorText?: string | null;
92
- profile?: ProfileData | null;
93
- };
94
-
95
- /** API response with HTTP status code. */
96
- export type ResponseWithHttpCode = {
97
- httpCode: number | null;
98
- response: Response | null;
99
- };
100
-
101
- // ---------------- Config / SDK models ----------------
102
-
103
- /** Application metadata. */
104
- export type AppInfo = {
105
- appID: string;
106
- appIID: string;
107
- appVer: string;
108
- };
109
-
110
- /** SDK configuration object. */
111
- export type AltcraftConfig = {
112
- apiUrl: string;
113
- rToken?: string | null;
114
- appInfo?: AppInfo | null;
115
- providerPriorityList?: string[] | null;
116
- enableLogging?: boolean | null;
117
-
118
- // -------- ANDROID-ONLY --------
119
- android_icon?: number | null;
120
- android_pushReceiverModules?: string[] | null;
121
- android_pushChannelName?: string | null;
122
- android_pushChannelDescription?: string | null;
123
- };
124
-
125
- /** Push token data. */
126
- export type TokenData = {
127
- provider: string | null;
128
- token: string | null;
129
- };
130
-
131
- /** SDK event emitted from native via NativeEventEmitter ("AltcraftSdkEvent"). */
132
- export type SdkEvent = {
133
- function: string;
134
- code: number | null;
135
- message: string;
136
- type: 'event' | 'error' | 'retryError';
137
- value?: Record<string, unknown> | null;
138
- };
139
-
140
- // ---------------- TurboModule Spec ----------------
141
-
142
- export interface Spec extends TurboModule {
143
- // init
144
-
145
- /** Initializes SDK with provided configuration. */
146
- initialize(config: AltcraftConfig): Promise<void>;
147
-
148
- // subscription
149
-
150
- /** Creates or updates push subscription. */
151
- pushSubscribe(
152
- sync: boolean | null,
153
- profileFields: { [key: string]: string } | null,
154
- customFields: { [key: string]: string } | null,
155
- cats: CategoryData[] | null,
156
- replace: boolean | null,
157
- skipTriggers: boolean | null
158
- ): void;
159
-
160
- /** Suspends active push subscription. */
161
- pushSuspend(
162
- sync: boolean | null,
163
- profileFields: { [key: string]: string } | null,
164
- customFields: { [key: string]: string } | null,
165
- cats: CategoryData[] | null,
166
- replace: boolean | null,
167
- skipTriggers: boolean | null
168
- ): void;
169
-
170
- /** Unsubscribes from push notifications. */
171
- pushUnSubscribe(
172
- sync: boolean | null,
173
- profileFields: { [key: string]: string } | null,
174
- customFields: { [key: string]: string } | null,
175
- cats: CategoryData[] | null,
176
- replace: boolean | null,
177
- skipTriggers: boolean | null
178
- ): void;
179
-
180
- /** Unsuspends current push subscription. */
181
- unSuspendPushSubscription(): Promise<ResponseWithHttpCode | null>;
182
-
183
- /** Returns status of the latest subscription. */
184
- getStatusOfLatestSubscription(): Promise<ResponseWithHttpCode | null>;
185
-
186
- /** Returns status of current subscription. */
187
- getStatusForCurrentSubscription(): Promise<ResponseWithHttpCode | null>;
188
-
189
- /** Returns subscription status for specific provider. */
190
- getStatusOfLatestSubscriptionForProvider(
191
- provider: string | null
192
- ): Promise<ResponseWithHttpCode | null>;
193
-
194
- // push payload (string-only)
195
-
196
- /** Handles incoming push payload (string-only). */
197
- takePush(message: { [key: string]: string } | null): void;
198
-
199
- // events
200
-
201
- /** Subscribes to SDK native events. */
202
- subscribeToEvents(): void;
203
-
204
- /** Unsubscribes from SDK native events. */
205
- unsubscribeFromEvent(): void;
206
-
207
- // required for NativeEventEmitter
208
-
209
- /** Required by NativeEventEmitter. */
210
- addListener(eventName: string): void;
211
-
212
- /** Required by NativeEventEmitter. */
213
- removeListeners(count: number): void;
214
-
215
- // token API
216
-
217
- /** Returns current push token. */
218
- getPushToken(): Promise<TokenData | null>;
219
-
220
- /** Sets push token for provider. */
221
- setPushToken(provider: string, token: string | null): Promise<void>;
222
-
223
- // sdk
224
-
225
- /** Clears all SDK state and stored data. */
226
- clear(): Promise<void>;
227
-
228
- /** Requests notification permission (iOS/Android). */
229
- requestNotificationPermission(): void;
230
-
231
- // mobile events
232
-
233
- /**
234
- * Sends a mobile event to the server.
235
- *
236
- */
237
- mobileEvent(
238
- sid: string,
239
- eventName: string,
240
- sendMessageId: string | null,
241
- payload: { [key: string]: string } | null,
242
- matching: { [key: string]: string } | null,
243
- matchingType: string | null,
244
- profileFields: { [key: string]: string } | null,
245
- subscription: { [key: string]: string } | null,
246
- utm: UTM | null
247
- ): void;
248
-
249
- // push event delivery
250
-
251
- /** Sends push delivery event. */
252
- deliveryEvent(
253
- message: { [key: string]: string } | null,
254
- messageUID: string | null
255
- ): void;
256
-
257
- // push event open
258
-
259
- /** Sends push open event. */
260
- openEvent(
261
- message: { [key: string]: string } | null,
262
- messageUID: string | null
263
- ): void;
264
-
265
- // set UserDefault
266
-
267
- /** Sets value in UserDefaults / SharedPreferences. */
268
- setUserDefaultsValue(
269
- suiteName: string | null,
270
- key: string,
271
- value: string | null
272
- ): void;
273
-
274
- // profile API
275
-
276
- /** Updates profile fields on the server. */
277
- updateProfileFields(
278
- profileFields: { [key: string]: string } | null,
279
- skipTriggers: boolean | null
280
- ): void;
281
-
282
- // token management
283
-
284
- /** Forces a push token refresh (delete + re-register). */
285
- forcedTokenUpdate(): Promise<void>;
286
-
287
- /** Deletes the device token for a given provider. */
288
- deleteDeviceToken(provider: string): Promise<void>;
289
-
290
- /** Changes the push provider priority list at runtime. */
291
- changePushProviderPriorityList(priorityList: string[]): Promise<void>;
292
-
293
- // push receiver helpers
294
-
295
- /** Checks whether a push payload belongs to Altcraft. */
296
- isAltcraftPush(message: { [key: string]: string } | null): boolean;
297
-
298
- // SDK lifecycle
299
-
300
- /** Allows re-running initial operations in this session (Android only). */
301
- unlockInitialOperationsInThisSession(): void;
302
-
303
- // iOS-only
304
-
305
- /** Sets the App Group name for shared storage (iOS only). */
306
- setAppGroup(groupName: string | null): void;
307
- }
308
-
309
- // ---------------- Export ----------------
310
-
311
- /** Native TurboModule instance. */
312
- const NativeSDK = TurboModuleRegistry.getEnforcing<Spec>('Sdk');
313
- export default NativeSDK;