Public SDK API
The SDK is split into modules. Each module is a separate npm package with its own API class, and the @altcraft/react-native-sdk package provides the AltcraftSDK wrapper class with the same methods on top of the modules.
// @altcraft/react-native-sdk — wrapper with the entire API
AltcraftSDK
// @altcraft/core
AltcraftCore
├─ static initialize(config: AltcraftConfig): Promise<void>
├─ static subscribeToEvents(handler: (event: SdkEvent) => void): void
├─ static unsubscribeFromEvents(handler: (event: SdkEvent) => void): void
├─ static clear(): Promise<void>
├─ static setJwtProvider(provider: () => Promise<string | null>): void
├─ static authenticate(): void
├─ static logOut(): void
├─ static isAuthenticated(): Promise<boolean>
├─ static setAppGroup(groupName: string | null): void
├─ static setUserDefaultsValue(suiteName: string | null, key: string, value: string | null): void
├─ static unlockInitialOperationsInThisSession(): void
└─ static readonly moduleEvents: CoreModuleEvents
// @altcraft/push
AltcraftPush
├─ static pushSubscribe(options?: PushSubscribeOptions): Promise<void>
├─ static pushSuspend(options?: PushSubscribeOptions): Promise<void>
├─ static pushUnSubscribe(options?: PushSubscribeOptions): Promise<void>
├─ static unSuspendPushSubscription(): Promise<ResponseWithHttpCode | null>
├─ static getStatusOfLatestSubscription(): Promise<ResponseWithHttpCode | null>
├─ static getStatusForCurrentSubscription(): Promise<ResponseWithHttpCode | null>
├─ static getStatusOfLatestSubscriptionForProvider(provider?: string | null): Promise<ResponseWithHttpCode | null>
├─ static getPushToken(): Promise<TokenData | null>
├─ static setPushToken(provider: string, token: string | null): void
├─ static forcedTokenUpdate(): Promise<void>
├─ static deleteDeviceToken(provider: string): Promise<void>
├─ static changePushProviderPriorityList(priorityList: string[]): Promise<void>
├─ static takePush(message: Record<string, string>): void
├─ static isAltcraftPush(message: Record<string, string>): boolean
├─ static requestNotificationPermission(): Promise<boolean>
├─ static deliveryEvent(options?: PushEventOptions): void
├─ static openEvent(options?: PushEventOptions): void
└─ static readonly moduleEvents: PushModuleEvents
// @altcraft/inapp
AltcraftInApp
├─ static inAppSubscribe(options?: InAppSubscribeOptions): Promise<void>
├─ static inAppUnsubscribe(options?: InAppSubscribeOptions): Promise<void>
├─ static setScreen(screen: string): void
├─ static trigger(name: string): void
├─ static getPlacements(): void
├─ static setAnimation(config: InAppAnimationConfig | null): void
├─ static clearAnimation(): void
├─ static readonly jsonContent: JsonContentApi
└─ static readonly moduleEvents: InAppModuleEvents
// @altcraft/target
AltcraftTarget
├─ static sendTarget(options: MobileEventOptions): void
└─ static readonly moduleEvents: TargetModuleEvents
// @altcraft/profile
AltcraftProfile
├─ static updateProfileFields(options?: UpdateProfileOptions): void
└─ static readonly moduleEvents: ProfileModuleEvents
The methods return Promise<void> or Promise<T | null> and do not expose the server response directly. Native call errors arrive as AltcraftException. Read the server result of operations and retry errors through subscribeToEvents().
Core
Initialization
initialize(config)
static initialize(config: AltcraftConfig): Promise<void>
Initializes the SDK with the given configuration. Called once at application startup, before the main SDK operations are performed.
| Parameter | Type | Description |
|---|---|---|
config | AltcraftConfig | Configuration object. The apiUrl field is required. |
Returns: Promise<void>.
Throws: AltcraftException with the codes ALTCRAFT_INIT_INVALID_CONFIG, ALTCRAFT_INIT_ERROR, SDK_ERROR.
import { AltcraftConfigBuilder } from '@altcraft/core';
import { AltcraftSDK } from '@altcraft/react-native-sdk';
import '@altcraft/push';
await AltcraftSDK.initialize(
new AltcraftConfigBuilder({ apiUrl: 'https://pxl-demo.altcraft.com' })
.pushConfig({ providerPriority: ['android-firebase'] })
.build()
);
clear()
static clear(): Promise<void>
Clears SDK data on the native side: local storage, saved tokens and pending operations. Cancels background tasks awaiting execution.
SDK events
subscribeToEvents(handler)
static subscribeToEvents(handler: (event: SdkEvent) => void): void
Subscribes a handler to native SDK events. Several handlers can listen to the same event source.
unsubscribeFromEvents(handler)
static unsubscribeFromEvents(handler: (event: SdkEvent) => void): void
Unsubscribes a specific handler. Pass the same function you used for the subscription.
import { AltcraftSDK, type SdkEvent } from '@altcraft/react-native-sdk';
const handler = (event: SdkEvent) => {
console.log(`[${event.type}] ${event.function}: ${event.message}`);
};
AltcraftSDK.subscribeToEvents(handler);
// Unsubscribe
AltcraftSDK.unsubscribeFromEvents(handler);
Events are identified by the string message and the type. Ready-made message constants are available in the module catalogs: AltcraftCore.moduleEvents, AltcraftPush.moduleEvents, AltcraftInApp.moduleEvents, AltcraftTarget.moduleEvents, AltcraftProfile.moduleEvents. Example:
import { AltcraftSDK } from '@altcraft/react-native-sdk';
import { AltcraftPush } from '@altcraft/push';
AltcraftSDK.subscribeToEvents((event) => {
if (event.message === AltcraftPush.moduleEvents.subscribeRequestSuccessful) {
// The subscription is created
}
});
The full list of messages is available in Full list of SDK events in the "SDK functionality" article.
Authentication
setJwtProvider(provider)
static setJwtProvider(provider: () => Promise<string | null>): void
Registers the JWT provider: the native side calls the passed function at the moment a request requiring authorization is executed and adds the received token to the header.
| Parameter | Type | Description |
|---|---|---|
provider | () => Promise<string | null> | Function that returns the current JWT token or null. |
Register the provider before the initialize() call and before the first operation that requires authorization.
AltcraftSDK.setJwtProvider(async () => await myBackend.getJwtToken());
authenticate()
static authenticate(): void
Starts authorization with the current JWT: the SDK obtains the token through the provider, performs an authorization request and switches the profile to the user from the token.
logOut()
static logOut(): void
Ends the user session: the SDK clears the profile data and starts an anonymous session.
isAuthenticated()
static isAuthenticated(): Promise<boolean>
Returns true if the SDK is authenticated and works with the user profile.
const isAuthenticated = await AltcraftSDK.isAuthenticated();
if (!isAuthenticated) {
AltcraftSDK.setJwtProvider(async () => await myBackend.getJwtToken());
AltcraftSDK.authenticate();
}
Native storage
setAppGroup(groupName)
static setAppGroup(groupName: string | null): void
Sets the App Group for the iOS SDK — the UserDefaults space shared between the application and the Notification Service Extension. On Android the method is a no-op; on iOS groupName must not be null.
setUserDefaultsValue(suiteName, key, value)
static setUserDefaultsValue(
suiteName: string | null,
key: string,
value: string | null
): void
Stores a string value: UserDefaults on iOS (with the specified suite) and the SDK SharedPreferences on Android (the suiteName parameter is ignored). value = null deletes the key.
unlockInitialOperationsInThisSession()
static unlockInitialOperationsInThisSession(): void
Unlocks initial operations in the current session of the Android application. On iOS the method is a no-op.
Push
Push subscription
pushSubscribe() / pushSuspend() / pushUnSubscribe()
type PushSubscribeOptions = {
sync?: boolean | null;
profileFields?: Record<string, unknown> | null;
customFields?: Record<string, unknown> | null;
cats?: CategoryData[] | null;
replace?: boolean | null;
skipTriggers?: boolean | null;
};
| Method | Subscription status | Success / error messages |
|---|---|---|
pushSubscribe() | subscribed | successful request: push/subscribe / failed request: push/subscribe |
pushSuspend() | suspended | successful request: push/suspend / failed request: push/suspend |
pushUnSubscribe() | unsubscribed | successful request: push/unsubscribe / failed request: push/unsubscribe |
| Parameter | Type | Description |
|---|---|---|
sync | boolean? | true — synchronous request on the SDK side; false — asynchronous; null — the native side default behavior. |
profileFields | Record<string, unknown>? | Profile fields. Values must be JSON-compatible. |
customFields | Record<string, unknown>? | Custom subscription fields. Scalar values are recommended. |
cats | CategoryData[]? | Subscription categories. |
replace | boolean? | When true, the SDK can replace existing subscriptions with the same push token. |
skipTriggers | boolean? | When true, the profile is ignored in mailing and scenario triggers. |
Returns: Promise<void> — the command is accepted by the bridge and the native SDK. The server result arrives through subscribeToEvents().
import { AltcraftSDK } from '@altcraft/react-native-sdk';
await AltcraftSDK.pushSubscribe({
sync: true,
profileFields: { _fname: 'Ivan', _lname: 'Petrov' },
customFields: { source: 'rn_app' },
cats: [{ name: 'developer_news', active: true }],
});
unSuspendPushSubscription()
static unSuspendPushSubscription(): Promise<ResponseWithHttpCode | null>
Resumes a suspended push subscription. Used for LogIn/LogOut transitions between profiles. Returns null if the native SDK did not return a response.
const result = await AltcraftSDK.unSuspendPushSubscription();
if (result == null) {
AltcraftSDK.pushSubscribe({ sync: true });
} else {
const subscription = result.response?.profile?.subscription ?? null;
if (result.httpCode === 200 && subscription == null) {
AltcraftSDK.pushSubscribe({ sync: true });
}
}
Subscription status
getStatusOfLatestSubscription() — status of the latest profile subscription.
getStatusForCurrentSubscription() — subscription status for the current push token and provider.
getStatusOfLatestSubscriptionForProvider(provider?) — status of the latest subscription by provider. If provider is not specified, the provider of the current token is used.
static getStatusOfLatestSubscription(): Promise<ResponseWithHttpCode | null>
static getStatusForCurrentSubscription(): Promise<ResponseWithHttpCode | null>
static getStatusOfLatestSubscriptionForProvider(
provider?: string | null
): Promise<ResponseWithHttpCode | null>
Returns: Promise<ResponseWithHttpCode | null> — null if there is no response. If response.error != 0, the server returned an error.
const result = await AltcraftSDK.getStatusForCurrentSubscription();
if (result?.response?.error) {
console.log('Status error:', result.response.errorText);
} else {
console.log(result?.response?.profile?.subscription?.status);
}
Push tokens
getPushToken()
static getPushToken(): Promise<TokenData | null>
Returns the current device push token data and the provider, or null if the token is unavailable.
setPushToken(provider, token)
static setPushToken(provider: string, token: string | null): void
Sets or clears the push token for the specified provider. token = null clears the token.
| Parameter | Type | Description |
|---|---|---|
provider | string | Provider identifier: android-firebase, android-huawei, android-rustore, ios-apns, ios-firebase, ios-huawei. |
token | string | null | Token value. null — clears the token. |
forcedTokenUpdate() — forced push token update.
deleteDeviceToken(provider) — deletes the device token for a provider.
changePushProviderPriorityList(priorityList) — changes the provider priority for the application runtime. Index 0 is the highest priority provider. The initial list is set in pushConfig({ providerPriority: [...] }).
await AltcraftSDK.changePushProviderPriorityList([
'android-firebase',
'android-huawei',
'android-rustore',
]);
Push notification handling
requestNotificationPermission()
static requestNotificationPermission(): Promise<boolean>
Requests notification permission: POST_NOTIFICATIONS on Android 13+ (on earlier versions it returns true immediately), UNUserNotificationCenter authorization on iOS.
takePush(message)
static takePush(message: Record<string, string>): void
Passes an incoming push payload to the SDK. On Android the payload goes through the common SDK pipeline: the provider is determined, the delivery event is sent, the notification is built and shown. On iOS the SDK builds a local notification from the _title and _body payload fields.
isAltcraftPush(message)
static isAltcraftPush(message: Record<string, string>): boolean
Checks whether the push message belongs to Altcraft. On iOS the method always returns false.
deliveryEvent(options?) / openEvent(options?)
type PushEventOptions = {
message?: Record<string, string> | null;
messageUID?: string | null;
};
Manual registration of push notification delivery and opening. On Android the events are sent to the platform; on iOS the methods are no-ops.
AltcraftSDK.deliveryEvent({
message: { _uid: 'push-message-uid-0001', _provider: 'android-firebase' },
messageUID: 'push-message-uid-0001',
});
AltcraftSDK.openEvent({
messageUID: 'push-message-uid-0001',
});
You can pass only message or only messageUID. If both values are missing, the SDK cannot identify the push message.
In-App
In-App subscription
inAppSubscribe() / inAppUnsubscribe()
type InAppSubscribeOptions = {
sync?: boolean | null;
profileFields?: Record<string, unknown> | null;
customFields?: Record<string, unknown> | null;
cats?: CategoryData[] | null;
replace?: boolean | null;
skipTriggers?: boolean | null;
};
The parameters match the push subscription parameters. Messages: successful request: inapp/subscribe / failed request: inapp/subscribe and successful request: inapp/unsubscribe / failed request: inapp/unsubscribe.
import { AltcraftSDK } from '@altcraft/react-native-sdk';
await AltcraftSDK.inAppSubscribe({ sync: true });
Showing In-App campaigns
setScreen(screen)
Sets the current application screen. The SDK uses this value to match In-App campaign placements that are configured to be shown on a specific screen.
trigger(name)
Fires an In-App trigger by name.
getPlacements()
Requests available In-App placements from the server. Needed when automatic requests are disabled in inAppConfig({ inAppAutoRequest: false }).
AltcraftSDK.setScreen('catalog');
AltcraftSDK.trigger('add_to_cart');
AltcraftSDK.getPlacements();
In-App campaign animation
setAnimation(config)
type InAppAnimationSpec = {
durationMs?: number | null; // default 350
delayMs?: number | null; // default 0
easing?: 'linear' | 'easeIn' | 'easeOut' | 'easeInOut' | null;
alphaFrom?: number | null;
alphaTo?: number | null;
translateXFrom?: number | null;
translateXTo?: number | null;
translateYFrom?: number | null;
translateYTo?: number | null;
scaleXFrom?: number | null;
scaleXTo?: number | null;
scaleYFrom?: number | null;
scaleYTo?: number | null;
rotationFrom?: number | null;
rotationTo?: number | null;
};
type InAppAnimationConfig = {
default?: InAppAnimationSpec | null;
campaigns?: { [campaignId: string]: InAppAnimationSpec | null } | null;
};
static setAnimation(config: InAppAnimationConfig | null): void
The animation is applied when an In-App campaign is shown: the native side animates the real native view from the *From values to the *To values. null means the neutral state (opacity 1, offset 0, scale 1, rotation 0). Closing animation is not supported.
Matching rules: a campaigns entry for a specific campaign takes precedence over default; null for a campaign disables the animation; campaigns without a match are shown without animation.
AltcraftSDK.setAnimation({
default: {
alphaFrom: 0,
alphaTo: 1,
translateYFrom: 24,
translateYTo: 0,
durationMs: 350,
easing: 'easeInOut',
},
campaigns: {
'42': { scaleXFrom: 0.8, scaleYFrom: 0.8, alphaFrom: 0, alphaTo: 1 },
'43': null, // campaign 43 is shown without animation
},
});
clearAnimation()
static clearAnimation(): void
Disables the In-App campaign display animation.
In-App JSON content
type JsonContentHandler = (json: string) => void;
type JsonContentApi = {
subscribe(handler: JsonContentHandler): void;
unsubscribe(): void;
};
static readonly jsonContent: JsonContentApi
Campaigns with the JSON content type are not displayed by the SDK: the application receives the raw campaign JSON and renders it itself. The native side supports a single subscriber, so a new subscribe() call replaces the previous handler.
AltcraftSDK.jsonContent.subscribe((json) => {
const campaign = JSON.parse(json);
// Rendering the campaign with application tools
});
AltcraftSDK.jsonContent.unsubscribe();
Target
Mobile events
sendTarget(options)
type MobileEventOptions = {
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;
};
static sendTarget(options: MobileEventOptions): void
Registers an Altcraft mobile event.
| Parameter | Type | Description |
|---|---|---|
sid | string | Pixel identifier. Must not be empty. |
eventName | string | Event name. Must not be empty. |
sendMessageId | string? | SMID of the sent message. |
payload | Record<string, unknown>? | Event data, JSON-compatible values. |
matching | Record<string, unknown>? | Matching data, for example { email: 'ivan.petrov@example.com' }. |
matchingType | string? | Matching type. |
profileFields | Record<string, unknown>? | Profile fields. |
subscription | Subscription? | Channel subscription, created by a factory function. |
utm | UTM? | UTM tags. |
import {
AltcraftSDK,
emailSubscription,
} from '@altcraft/react-native-sdk';
AltcraftSDK.sendTarget({
sid: 'pixel-100000000000000000000000',
eventName: 'purchase',
payload: { order_id: 'A-1001', amount: 3990, currency: 'RUB' },
utm: { source: 'rn_app', medium: 'push', campaign: 'summer_campaign' },
subscription: emailSubscription({
resourceId: 10,
email: 'user@example.com',
status: 'subscribed',
cats: ['promo'],
}),
});
Profile
updateProfileFields(options?)
type UpdateProfileOptions = {
profileFields?: Record<string, unknown> | null;
skipTriggers?: boolean | null;
};
static updateProfileFields(options?: UpdateProfileOptions): void
Updates profile fields on the server.
| Parameter | Type | Description |
|---|---|---|
profileFields | Record<string, unknown>? | Map of profile fields to update. |
skipTriggers | boolean? | When true, the profile is ignored in mailing and scenario triggers. |
import { AltcraftSDK } from '@altcraft/react-native-sdk';
AltcraftSDK.updateProfileFields({
profileFields: { _fname: 'Ivan', _lname: 'Petrov' },
skipTriggers: false,
});
Data models
AltcraftConfig and AltcraftConfigBuilder
type AltcraftConfig = {
apiUrl: string;
rToken?: string | null;
appInfo?: AppInfo | null;
enableLogging?: boolean | null;
moduleConfigs?: string | null;
};
type AppInfo = {
appID: string;
appIID: string;
appVer: string;
};
class AltcraftConfigBuilder {
constructor(core: {
apiUrl: string;
rToken?: string | null;
appInfo?: AppInfo | null;
enableLogging?: boolean | null;
});
addModule(moduleId: string, config: Record<string, unknown>): this;
build(): AltcraftConfig;
}
The builder mirrors the native AltcraftConfiguration.Builder: common parameters are set in the constructor, module configurations are added by the pushConfig() and inAppConfig() extension methods, which are available when the corresponding package is imported. The core passes the module map to the native side in the moduleConfigs field without interpreting its content.
PushConfig and InAppConfig
type PushConfig = {
providerPriority?: string[] | null;
icon?: number | null; // Android-only
iconName?: string | null; // Android-only
pushReceiverModules?: string[] | null; // Android-only
pushChannelName?: string | null; // Android-only
pushChannelDescription?: string | null; // Android-only
};
type InAppConfig = {
inAppAutoRequest?: boolean | null;
placementsRequestIntervalMs?: number | null;
maxPlacements?: number | null;
};
| Field | Type | Description |
|---|---|---|
PushConfig.providerPriority | string[]? | Provider priority. Index 0 is the highest priority. |
PushConfig.icon | number? | Notification icon resource ID (Android). Takes precedence over iconName. |
PushConfig.iconName | string? | Notification icon resource name (Android): drawable, then mipmap. |
PushConfig.pushReceiverModules | string[]? | Packages with AltcraftPushReceiver implementations (Android). |
PushConfig.pushChannelName | string? | Notification channel name (Android). |
PushConfig.pushChannelDescription | string? | Notification channel description (Android). |
InAppConfig.inAppAutoRequest | boolean? | Automatic placement requests. Defaults to true. |
InAppConfig.placementsRequestIntervalMs | number? | Interval between automatic requests in milliseconds. Defaults to 30 minutes, minimum 15 minutes. |
InAppConfig.maxPlacements | number? | Maximum number of placements in local storage. Defaults to 500. |
SdkEvent
type SdkEvent = {
function: string;
code: number | null;
message: string;
type: 'event' | 'error' | 'retryError';
value?: Record<string, unknown> | null;
timestamp?: string | null;
};
| Field | Type | Description |
|---|---|---|
function | string | Name of the SDK function that raised the event. |
code | number | null | HTTP response code if the event is related to a request. |
message | string | Event message — the main event identifier. |
type | 'event' | 'error' | 'retryError' | Event type. |
value | Record<string, unknown>? | Additional data, for example response_with_http_code. |
timestamp | string? | Timestamp in yyyy-MM-dd HH:mm:ss.SSS format. |
TokenData and ResponseWithHttpCode
type TokenData = {
provider: string;
token: string;
};
type ResponseWithHttpCode = {
httpCode: number;
response: {
error?: number | null;
errorText?: string | null;
profile?: {
id?: string | null;
status?: string | null;
isTest?: boolean | null;
subscription?: {
subscriptionId?: string | null;
hashId?: string | null;
provider?: string | null;
status?: string | null;
fields?: Record<string, string> | null;
cats?: CategoryData[] | null;
} | null;
} | null;
} | null;
};
| Field | Type | Description |
|---|---|---|
TokenData.provider | string | Provider identifier. |
TokenData.token | string | Push token value. |
ResponseWithHttpCode.httpCode | number | HTTP response code. |
ResponseWithHttpCode.response.error | number? | Internal server error code (0 — no errors). |
ResponseWithHttpCode.response.errorText | string? | Error text. |
ResponseWithHttpCode.response.profile.subscription.status | string? | Status: subscribed, suspended, unsubscribed. |
CategoryData
type CategoryData = {
name?: string | null;
title?: string | null;
steady?: boolean | null;
active?: boolean | null;
};
Subscription category. When a push request is sent, only the name and active fields are used; title and steady are filled in SDK responses.
Subscription and UTM
type EmailSubscription = {
type: 'email';
resourceId: number;
email: string;
status?: string | null;
priority?: number | null;
customFields?: Record<string, unknown> | null;
cats?: string[] | null;
};
type SmsSubscription = {
type: 'sms';
resourceId: number;
phone: string;
status?: string | null;
priority?: number | null;
customFields?: Record<string, unknown> | null;
cats?: string[] | null;
};
type PushSubscription = {
type: 'push';
resourceId: number;
provider: string;
subscriptionId: string;
status?: string | null;
priority?: number | null;
customFields?: Record<string, unknown> | null;
cats?: string[] | null;
};
type CcDataSubscription = {
type: 'cc_data';
resourceId: number;
channel: string;
ccData: Record<string, unknown>;
status?: string | null;
priority?: number | null;
customFields?: Record<string, unknown> | null;
cats?: string[] | null;
};
type Subscription =
| EmailSubscription
| SmsSubscription
| PushSubscription
| CcDataSubscription;
Factory functions: emailSubscription(), smsSubscription(), pushSubscription(), ccDataSubscription(). The subscription object can also be assembled manually — the only requirement is that the type field matches the channel type.
import { pushSubscription } from '@altcraft/react-native-sdk';
const subscription = pushSubscription({
resourceId: 10,
provider: 'android-firebase',
subscriptionId: 'provider-sub-id',
status: 'subscribed',
});
type UTM = {
source?: string | null;
medium?: string | null;
campaign?: string | null;
content?: string | null;
keyword?: string | null;
temp?: string | null;
};
ActionFieldBuilder
class ActionFieldBuilder {
constructor(key: string);
set(value: unknown): ActionFieldEntry;
unset(value: unknown): ActionFieldEntry;
incr(value: unknown): ActionFieldEntry;
add(value: unknown): ActionFieldEntry;
delete(value: unknown): ActionFieldEntry;
upsert(value: unknown): ActionFieldEntry;
}
function actionField(key: string): ActionFieldBuilder;
A builder for structured management of profile fields. It produces an object compatible with the native SDK: merge the result with profileFields before passing it to pushSubscribe(), updateProfileFields() or a mobile event.
| Method | Description |
|---|---|
set(value) | Set the field to the given value. |
unset(value) | Delete the field value. |
incr(value) | Increase a numeric field by the given value. |
add(value) | Add a value to a set/array field. |
delete(value) | Remove a value from a set/array field. |
upsert(value) | Set the field if it is missing; update it if it exists. |
import { actionField } from '@altcraft/core';
import { AltcraftSDK } from '@altcraft/react-native-sdk';
const profileFields = {
...actionField('_fname').set('Ivan'),
...actionField('login_count').incr(1),
...actionField('visited_pages').add('/settings'),
};
AltcraftSDK.updateProfileFields({ profileFields });
Exceptions
class AltcraftException extends Error {
readonly code: string;
}
The exception thrown by SDK modules on native call errors. Check code.
| Code | Description |
|---|---|
ALTCRAFT_INIT_INVALID_CONFIG | Invalid SDK configuration. |
ALTCRAFT_INIT_ERROR | SDK initialization error. |
SDK_ERROR | Generic native bridge error. |
import { AltcraftException } from '@altcraft/core';
try {
await AltcraftSDK.initialize(config);
} catch (e) {
if (e instanceof AltcraftException) {
console.log(`SDK error (${e.code}): ${e.message}`);
}
}
Constants
Push notification providers:
| Provider | Value |
|---|---|
| FCM (Android) | android-firebase |
| HMS (Android) | android-huawei |
| RuStore (Android) | android-rustore |
| APNS (iOS) | ios-apns |
| FCM (iOS) | ios-firebase |
| HMS (iOS) | ios-huawei |
Subscription statuses:
| Status | Value |
|---|---|
| Subscribed | subscribed |
| Unsubscribed | unsubscribed |
| Suspended | suspended |