Skip to main content
Altcraft Docs LogoAltcraft Docs Logo
User guide iconUser guide
Developer guide iconDeveloper guide
Admin guide iconAdmin guide
English
  • Русский
  • English
Login
    User API documentationAPI interactionMatching
      Profilesarrow
    • Import profileUpdate profileImport multiple profilesUpdate multiple profilesAdd multiple profilesAdd profile to databaseImport profile to RabbitMQGet profile dataUploading profiles to a fileDelete profileSubscription fields functional updateDatabase fields functional updateMerging multiple profilesUnsubscribe profile from resourceProfile splitting
        Subscriptionsarrow
      • Add or edit subscriptionGet all profile subscriptionsGet all subscriptions from multiple profilesGet profile subscriptionDelete profile subscriptionRestore deleted subscriptionSuspend all subscriptionsUnsuspend all suspended subscriptions
        Action historyarrow
      • Get profile action historyGet multiple profiles action history
        Profile relationsarrow
      • Attach relationDetach relationModify relation propertiesOverwrite relation propertiesGet profile relations infoGet profile relations info
      Get data for multiple profiles
      Databasesarrow
    • Get database statisticsUpdate statistics on databaseGet database listGet database informationGet database fieldsDatabase wipe
      Resourcesarrow
    • Get resource statisticsUpdate statistics on resourceGet resources listGet resource informationGet resource subscription fields
      Segmentsarrow
    • Create segmentGet statistics on resourceUpdate statistics on segmentAdd or remove profileGet profile data in a static segmentUpdate segmentGet segment informationGet segments listDelete segment
      Suppression listsarrow
    • Create suppression listUpdate suppression listGet suppression list infoGet the list of suppression listsDelete suppression listUpload suppression list data to file
        Suppression list actionsarrow
      • Check if email is suppressedAdd email to suppression listAdd multiple emails to suppression listRemove email from suppression listRemove all emails from suppression listCheck if domain is suppressedAdd domain to suppression listAdd multiple domains to suppression listRemove domain from suppression listRemove all domains from suppression listCheck if phone number is suppressedAdd phone number to suppression listAdd multiple phones to suppression listRemove phone number from suppression listRemove all phone numbers from suppression list
      Templates and fragmentsarrow
    • Get templates listGet template infoDelete templateAdd templateUpdate templateChannel object
      Campaignsarrow
    • Get campaign informationGet campaign listActivate campaignComplete campaignDeactivate campaignGet campaign status
      Mailingsarrow
    • Activate mailingDeactivate mailingGet mailing listGet mailing informationGet mailing logClone mailingDelete mailingGet mailing status
        Broadcast mailingsarrow
      • Get broadcasts listGet broadcast informationCreate broadcast mailingUpdate broadcast mailingLaunch a broadcast mailing
        Regular mailingsarrow
      • Get regular mailings listGet regular mailing informationCreate regular mailingUpdate regular mailingLaunch a regular mailing
        Trigger mailingsarrow
      • Get trigger mailings listGet trigger mailing informationCreate trigger mailingUpdate trigger mailingTrigger launch (API call)Profile import + trigger mailing launchTask for bulk trigger launchTask for bulk profiles import + trigger launchBulk trigger launchBulk profiles import + trigger mailing launchClone a trigger mailingData array
      Automation scenariosarrow
    • Engage profile in scenarioImport and engage profile in scenarioBatch import and engage profiles in a scenarioTask for batch import and engaging profiles in the scenarioGet scenarios listActivate scenarioDeactivate scenarioGet scenario informationChange scenario priority
      Loyalty Programsarrow
    • Get profile tier in a loyalty programExport points transactionsExpiring points for a periodGet profile account transactionsGet trigger promotions listAccrue points to a memberRedeem member pointsCommit temporary transactionPreliminary Order CalculationOrder ConfirmationRoll back temporary transactionCancel points transactionGet points account balanceRegister member in a loyalty programBatch adding participants to loyalty programTask for batch add participants to loyalty programRemove member from loyalty program
      Formsarrow
    • Get form informationGet form listExport form fill data by userExport form fill dataPublish formUnpublish formDelete form
      Promo codesarrow
    • Import promo codesGet promo code informationActivate promo codeUpdate promo codeAttach promo codeDetach promo codeGet all promo codes
      Goalsarrow
    • Goals and goal values registration
      Application push notificationsarrow
    • Processing and adding a subscriptionAdd app push events
      Marketarrow
      • Market objectsarrow
      • Order data objectProduct data objectSKU data objectCategories arrayCustom fields array
        Ordersarrow
      • Import order and item statusesGet orders listDelete orderGet order statusUpdate order line status
        Products and SKUarrow
      • Import products, SKUs and categoriesImport SKUs and categoriesGet products listGet SKUs listDelete productsDelete SKU
      Analytic reportsarrow
    • Get summary reportGet soft bounces reportGet undeliveries report
      Sendersarrow
    • Get senders list
        Virtual senders (Smart accounts only)arrow
      • Get virtual senders listGet virtual sender informationClone virtual senderCreate virtual senderUpdate virtual senderDelete virtual sender
      External datatables queriesarrow
      • Segmentation queriesarrow
      • Add segmentation queryUpdate segmentation queryGet segmentation query informationGet segmentation queries listDelete segmentation query
        Template queriesarrow
      • Add template queryUpdate template queryGet template query informationGet template queries listDelete template query
      Objectsarrow
    • AKMTA objectContent objectCustom channels rulesEmail rule objectFile objectProfile data objectSMS rule objectSender objectSender typesStart schedule objectSubscription objectTrigger types
      Miscellaneousarrow
    • Upload fileGet message web versionPush providersDeduplication of requestsHow to send API request with RabbitMQList of gender identificationsObtain valid values for fields: browsers, devices, tz, oses, languages
    Importing the API collection in PostmanList of API endpoints
      SDKarrow
      • mSDKarrow
        • Androidarrow
        • Quick startSDK functionalitySDK ConfigurationPublic SDK API
            Provider setuparrow
          • Firebase Cloud MessagingHuawei Mobile ServicesRuStore
          iOSarrow
        • Quick startSDK configurationSDK functionalityPublic SDK API
            Provider configurationarrow
          • Apple Push Notification ServiceFirebase Cloud MessagingHuawei Mobile Services
          React Native (Android/iOS)arrow
        • Quick startSDK configurationSDK functionalityPublic SDK APIProvider setup
          Flutter (Android/iOS)arrow
        • Quick StartSDK ConfigurationSDK FunctionalitySDK Public APIProvider Setup
        Working with role and JWT tokens
      Web Push SDK
  • SDK
  • mSDK
  • React Native (Android/iOS)
  • SDK functionality

SDK functionality

tip

You must first configure the SDK for your application. Detailed instructions are available here.

SDK operations are grouped by module. The AltcraftSDK wrapper class from the @altcraft/react-native-sdk package duplicates the module methods, so the examples below use both AltcraftSDK.pushSubscribe() and AltcraftPush.pushSubscribe() — this is the same call. If individual modules are connected to the project, call the methods of the module class (AltcraftPush, AltcraftInApp, AltcraftTarget, AltcraftProfile, AltcraftCore).

Working with subscription statuses​


Changing the subscription status​

AltcraftPush (@altcraft/push)
├─ static pushSubscribe(options?: PushSubscribeOptions): Promise<void> // status = subscribed
├─ static pushSuspend(options?: PushSubscribeOptions): Promise<void> // status = suspended
├─ static pushUnSubscribe(options?: PushSubscribeOptions): Promise<void> // status = unsubscribed
└─ static unSuspendPushSubscription(): Promise<ResponseWithHttpCode | null>

type PushSubscribeOptions = {
sync?: boolean | null;
profileFields?: Record<string, unknown> | null;
customFields?: Record<string, unknown> | null;
cats?: CategoryData[] | null;
replace?: boolean | null;
skipTriggers?: boolean | null;
};
  • pushSubscribe() — subscribes to push notifications;
  • pushSuspend() — suspends the push subscription (notifications do not arrive, but no unsubscription event is created in the user profile);
  • pushUnSubscribe() — cancels the push subscription;
  • unSuspendPushSubscription() — used to build LogIn and LogOut transitions.

The pushSubscribe(), pushSuspend() and pushUnSubscribe() functions have the same signature and accept a single options object.


sync: boolean | null
Default: null — the native side behavior (true)
Required: No
Description: Flag that sets whether the request is executed synchronously.

Successful request execution:

If the request succeeds, an SDK event of the event type is created with the message:

FunctionSuccess message
pushSubscribe()successful request: push/subscribe
pushSuspend()successful request: push/suspend
pushUnSubscribe()successful request: push/unsubscribe

Ready-made message constants are available in the module catalog: AltcraftPush.moduleEvents.subscribeRequestSuccessful, AltcraftPush.moduleEvents.suspendRequestSuccessful, AltcraftPush.moduleEvents.unsubscribeRequestSuccessful.

The contents of event.value depend on the synchronization flag:

If sync == true
ResponseWithHttpCode
├─ httpCode: 200
└─ response
├─ error: 0
├─ errorText: ""
└─ profile
├─ id: "000000000000000000000000"
├─ status: "subscribed"
├─ isTest: false
└─ subscription
├─ subscriptionId: "provider-subscription-id"
├─ hashId: "7f31a9c4"
├─ provider: "android-firebase"
├─ status: "subscribed"
├─ fields
│ ├─ _os: "Android"
│ ├─ _os_ver: "14"
│ ├─ _device_type: "mob"
│ ├─ _device_model: "Pixel 7"
│ └─ _app_ver: "1.0.0"
└─ cats
└─ [ { name: "developer_news", active: true } ]

For a synchronous request, event.value exposes http_code and response with the error, error_text and profile fields under the response_with_http_code key. The JavaScript wrapper normalizes them into ResponseWithHttpCode with the httpCode, response.error, response.errorText and response.profile fields.

If sync == false
ResponseWithHttpCode
├─ httpCode: number | null
└─ response: Response | null
├─ error: number | null
├─ errorText: string | null
└─ profile: null // usually null for an asynchronous request

For an asynchronous request profile is always null — profile and subscription data are not returned in the event.


Failed request execution:

If the request fails, an event is created with the following messages:

Errors without an automatic retry on the SDK side — event type error:

  • failed request: push/subscribe — notification subscription;
  • failed request: push/suspend — subscription suspension;
  • failed request: push/unsubscribe — unsubscription.

Errors with an automatic retry on the SDK side — event type retryError:

  • push subscribe retry limit — the subscription retry limit is exhausted;
  • push event retry limit — the push event sending retry limit is exhausted.

Event contents:

  • only http_code if the Altcraft server was unavailable;
  • error and error_text if the server returned an error.
Reading event values
import { AltcraftCore } from '@altcraft/core';
import { AltcraftPush } from '@altcraft/push';

const responseMessages = [
AltcraftPush.moduleEvents.subscribeRequestSuccessful,
AltcraftPush.moduleEvents.suspendRequestSuccessful,
AltcraftPush.moduleEvents.unsubscribeRequestSuccessful,
AltcraftPush.moduleEvents.subscribeRequestFailed,
AltcraftPush.moduleEvents.suspendRequestFailed,
AltcraftPush.moduleEvents.unsubscribeRequestFailed,
];

AltcraftCore.subscribeToEvents((event) => {
if (!responseMessages.includes(event.message)) return;

const raw = event.value?.response_with_http_code as
| Record<string, unknown>
| undefined;

if (raw == null) return;

const httpCode = raw.http_code ?? raw.httpCode;
const response = raw.response as Record<string, unknown> | null;
const profile = response?.profile as Record<string, unknown> | null;
const subscription = profile?.subscription as Record<string, unknown> | null;

console.log('httpCode=', httpCode, 'error=', response?.error);
console.log('subscriptionId=', subscription?.subscription_id);
});

profileFields: Record<string, unknown> | null
Default: null
Required: No
Description: Object containing profile fields.

The parameter accepts both system fields (for example, _fname for the first name or _lname for the last name) and optional fields (created manually in the platform interface in advance). Allowed structures (JSON-compatible):

  • Scalar values: string, boolean, number, null
  • Objects: Record<string, unknown>
  • Arrays: unknown[]

If an invalid optional field is passed, the request fails:

failed request: push/subscribe
http code: 400
error: 400
error_text: Platform profile processing error: with field "field_name": Incorrect field
AltcraftSDK.pushSubscribe({
sync: true,
profileFields: {
_fname: 'Ivan',
_lname: 'Petrov',
_email: 'ivan.petrov@example.com',
},
});

customFields: Record<string, unknown> | null
Default: null
Required: No
Description: Object containing subscription fields.

The parameter accepts both system fields (for example, _device_model for the device model or _os for the operating system) and optional fields (created manually in the platform interface in advance). Allowed value types (JSON-compatible, scalars only):

  • string
  • boolean
  • number
  • null

If an invalid optional field is passed, the request fails:

failed request: push/subscribe
http code: 400
error: 400
error_text: Platform profile processing error: field "field_name" is not valid: failed convert custom field
AltcraftSDK.pushSubscribe({
customFields: {
source: 'rn_app',
build: '100',
},
});
Note

Most system subscription fields are collected by the SDK automatically and added to push requests. These system fields are: "_os", "_os_tz", "_os_language", "_device_type", "_device_model", "_device_name", "_os_ver", "_ad_track", "_ad_id".


cats: CategoryData[] | null
Default: null
Required: No
Description: Subscription categories.

The category structure is defined by the CategoryData type:

type CategoryData = {
name?: string | null;
title?: string | null;
steady?: boolean | null;
active?: boolean | null;
};

When sending a push request with categories, use only the name and active fields. The title and steady fields are not used in request processing — they are filled when subscription information is received.

AltcraftSDK.pushSubscribe({
cats: [
{ name: 'developer_news', active: true },
{ name: 'product_updates', active: false },
],
});

The categories used in the request must be created and added to the resource in the Altcraft Platform in advance. If the request uses a category that is not added to the resource, the request fails:

failed request: push/subscribe
http code: 400
error: 400
error_text: Platform profile processing error: field "subscriptions.cats" is not valid: category not found in resource

replace: boolean | null
Default: null
Required: No
Description: When the flag is enabled, all subscriptions of other profiles with the same push token in the current database are set to the unsubscribed status after a successful request.


skipTriggers: boolean | null
Default: null
Required: No
Description: When the flag is enabled, the profile that contains this subscription is ignored in mailing and scenario triggers.


Request implementation examples

Example of a push subscription request

Minimal working configuration:

AltcraftSDK.pushSubscribe();

Passing all available parameters:

AltcraftSDK.pushSubscribe({
sync: true,
profileFields: { _fname: 'Ivan', _lname: 'Petrov' },
customFields: { source: 'rn_app' },
cats: [{ name: 'developer_news', active: true }],
replace: false,
skipTriggers: false,
});
Note

For pushSubscribe, pushSuspend and pushUnSubscribe the SDK retries the request automatically when the HTTP response code is in the 500..599 range. The request is not retried when the response code is outside this range. When the retry limit is exhausted, an event of the retryError type arrives with the message push subscribe retry limit, and the request is removed from the local queue.


The unSuspendPushSubscription() function

The static unSuspendPushSubscription(): Promise<ResponseWithHttpCode | null> function is intended for LogIn and LogOut transitions. It works as follows:

  • searches for subscriptions with the same push token as the current one that do not belong to the profile the current JWT token points to;
  • changes the status of the found subscriptions from subscribed to suspended;
  • changes the status in the subscriptions of the profile the current JWT points to from suspended to subscribed (if the profile the JWT points to exists and contains subscriptions);
  • returns ResponseWithHttpCode | null, where response.profile is the current profile the JWT points to (if the profile does not exist, null is returned).
Recommended implementation of LogIn and LogOut transitions

LogIn transition

  • An anonymous user opens the application. This user is assigned JWT_1, which points to the #1Anonymous database;
  • A push subscription is created and the profile is created in the #1Anonymous database;
  • The user signs up and is assigned JWT_2, which points to the #2Registered database;
  • The unSuspendPushSubscription() function is called: the anonymous user subscription in the #1Anonymous database is suspended;
  • A profile search is performed in the #2Registered database to restore the subscription;
  • Since no subscription with this push token exists in the #2Registered database, the function returns null;
  • After receiving null, you can call pushSubscribe(), which creates a new profile in the #2Registered database.

LogOut transition

  • The user logged out of the profile on the application side (logOut());
  • The user is assigned JWT_1, which points to the #1Anonymous database;
  • The unSuspendPushSubscription() function is called: it suspends the subscription in the #2Registered database and changes the subscription status in the #1Anonymous database to subscribed;
  • The request returns the #1Anonymous != null profile: the subscription already exists, a new one is not required.

Implementation example:

import { AltcraftSDK } from '@altcraft/react-native-sdk';

async function unSuspend(logIn: boolean) {
if (logIn) {
AltcraftSDK.authenticate();
} else {
AltcraftSDK.logOut();
}

const result = await AltcraftSDK.unSuspendPushSubscription();

if (result == null) {
AltcraftSDK.pushSubscribe();
return;
}

const subscription = result.response?.profile?.subscription ?? null;

if (result.httpCode === 200 && subscription == null) {
AltcraftSDK.pushSubscribe();
}
}

Requesting the subscription status​

AltcraftSDK
├─ static getStatusOfLatestSubscription(): Promise<ResponseWithHttpCode | null>
├─ static getStatusForCurrentSubscription(): Promise<ResponseWithHttpCode | null>
└─ static getStatusOfLatestSubscriptionForProvider(
provider?: string | null
): Promise<ResponseWithHttpCode | null>

Subscription status request functions:

  • getStatusOfLatestSubscription() — status of the latest profile subscription;
  • getStatusForCurrentSubscription() — subscription status for the current token/provider;
  • getStatusOfLatestSubscriptionForProvider() — status of the latest subscription by provider. If null is passed, the provider of the current token is used.

getStatusOfLatestSubscription()

Function that returns the status of the latest profile subscription. Returns response.profile.subscription — the last subscription created in the profile. If no such subscription exists, null is returned.

const result = await AltcraftSDK.getStatusOfLatestSubscription();

getStatusForCurrentSubscription()

Function that returns the subscription status for the current token/provider. Returns response.profile.subscription — the subscription found by the current push token and provider. If no such subscription exists, null is returned.

const result = await AltcraftSDK.getStatusForCurrentSubscription();

getStatusOfLatestSubscriptionForProvider(provider)

Function that returns the status of the latest subscription by provider. If the provider is not specified, the provider of the current token is used.

const result = await AltcraftSDK.getStatusOfLatestSubscriptionForProvider(
'android-firebase'
);

Below is an example of extracting profile, subscription and category data from the response of the status functions. This approach applies to all status functions:

Data from status functions
import { AltcraftSDK } from '@altcraft/react-native-sdk';

async function readStatus() {
const result = await AltcraftSDK.getStatusForCurrentSubscription();

if (result == null) return;

const { httpCode, response } = result;
const error = response?.error ?? null;
const errorText = response?.errorText ?? null;
const subscription = response?.profile?.subscription ?? null;

console.log('httpCode=', httpCode, 'error=', error, 'errorText=', errorText);
console.log('status=', subscription?.status, 'cats=', subscription?.cats);
}

Managing provider push tokens​


tip

On the native side of the application you can use the functions described in the articles for the corresponding platforms: Android and iOS.

AltcraftSDK
├─ 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>

Functions for working with the provider token in the SDK:

  • setPushToken() — sets the device and provider push token;
  • getPushToken() — returns the current push token;
  • forcedTokenUpdate() — forced token update;
  • deleteDeviceToken() — deletes the device token for a provider;
  • changePushProviderPriorityList() — changes the provider priority for the application runtime.

setPushToken(provider, token)

The function is intended to set the device and provider push token.

  • In React Native no context is passed — token saving and storage are performed on the native side of the SDK.
  • token: null — clears the token for the specified provider.
import { AltcraftSDK } from '@altcraft/react-native-sdk';

function saveFcmToken(token: string) {
AltcraftSDK.setPushToken('android-firebase', token);
}

Example of passing the token when a new token is received:

function onNewToken(provider: string, token: string) {
AltcraftSDK.setPushToken(provider, token);
}

getPushToken()

The function returns the current device push token data and provider as TokenData.

type TokenData = {
provider: string;
token: string;
};

If the token is unavailable, null is returned.

const data = await AltcraftSDK.getPushToken();

console.log('provider=', data?.provider, 'token=', data?.token);

Registering and passing push notifications to the SDK​


In native code​

To configure push notification handling in a React Native project, use the native SDK instructions.

Android:

  • Connecting push providers
  • Preparing the SDK for push providers
  • Passing push notifications to the SDK

iOS:

  • Connecting push providers
  • Configuring the application AppDelegate
  • Preparing the NSE
  • Working with push notifications
Important

The takePush() method is available on both platforms. 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 and passes it to AltcraftNSE; rich push (images, actions) is still handled in the Notification Service Extension.


In React Native​

If incoming push notifications are handled on the JavaScript side, pass the payload to the SDK with the takePush() method.

static takePush(message: Record<string, string>): void

where message is the push notification data converted to an object with string values.

FCM (Firebase Cloud Messaging)

Install the required dependencies:

npm i @react-native-firebase/app @react-native-firebase/messaging

Handling push notifications via FCM:

Background push

import messaging from '@react-native-firebase/messaging';
import { AltcraftSDK } from '@altcraft/react-native-sdk';

messaging().setBackgroundMessageHandler(async (message) => {
const data = message.data ?? {};
const payload: Record<string, string> = {};

Object.entries(data).forEach(([key, value]) => {
payload[key] = value == null ? '' : String(value);
});

if (Object.keys(payload).length > 0) {
AltcraftSDK.takePush(payload);
}
});

Foreground push

messaging().onMessage(async (message) => {
const data = message.data ?? {};
const payload: Record<string, string> = {};

Object.entries(data).forEach(([key, value]) => {
payload[key] = value == null ? '' : String(value);
});

if (Object.keys(payload).length > 0) {
AltcraftSDK.takePush(payload);
}
});

This approach can be combined with the native push service: notifications can be handled natively and passed to JavaScript/the Altcraft SDK in parallel for business logic.


In-App notifications​


AltcraftInApp (@altcraft/inapp)
├─ 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

The In-App module is responsible for showing In-App campaigns: channel subscription, matching placements to the current screen, firing triggers, display animation and passing campaigns with JSON content to the application.


Subscribing to In-App notifications​

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 and have the same purpose. Success and error arrive as events:

OperationSuccessError
inAppSubscribe()successful request: inapp/subscribefailed request: inapp/subscribe
inAppUnsubscribe()successful request: inapp/unsubscribefailed request: inapp/unsubscribe
import { AltcraftSDK } from '@altcraft/react-native-sdk';

await AltcraftSDK.inAppSubscribe({
sync: true,
cats: [{ name: 'promo', active: true }],
});

Showing In-App campaigns​

setScreen(screen)

Sets the current application screen. The SDK matches In-App campaign placements that are configured to be shown on a specific screen by this value. Call the method on every screen transition.

AltcraftSDK.setScreen('catalog');

trigger(name)

Fires an In-App trigger by name. Used for campaigns with trigger-based display.

AltcraftSDK.trigger('add_to_cart');

getPlacements()

Requests available In-App placements from the server. The method is needed when automatic placement requests are disabled in the module configuration (inAppConfig({ inAppAutoRequest: false })).

AltcraftSDK.getPlacements();
Note

The interval between automatic placement requests is set by the inAppConfig({ placementsRequestIntervalMs }) parameter at SDK initialization. The minimum value is 15 minutes (900000 ms); a lower value is clamped to the minimum on the native side.


In-App campaign display animation​

static setAnimation(config: InAppAnimationConfig | null): void
static clearAnimation(): void

The native side animates the real native view, so the configuration describes the starting and target states: the *From values are applied before the display, the *To values are the animation target. 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 companyId takes precedence over default;
  • null for a campaign disables the animation of that campaign;
  • campaigns without a match are shown without animation;
  • every setAnimation() call replaces the previous configuration.
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
},
});

// Fully disabling the animation
AltcraftSDK.clearAnimation();
FieldTypeDefaultDescription
durationMsnumber350Animation duration in milliseconds.
delayMsnumber0Delay before the animation starts.
easing'linear' | 'easeIn' | 'easeOut' | 'easeInOut'easeInOutAnimation curve.
alphaFrom / alphaTonumber1Opacity.
translateXFrom / translateXTonumber0Horizontal offset (dp on Android, pt on iOS).
translateYFrom / translateYTonumber0Vertical offset (dp on Android, pt on iOS).
scaleXFrom / scaleXTonumber1Horizontal scale.
scaleYFrom / scaleYTonumber1Vertical scale.
rotationFrom / rotationTonumber0Rotation in degrees.

Campaigns with JSON content​

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
});

// Unsubscribe
AltcraftSDK.jsonContent.unsubscribe();

Mobile events​

AltcraftTarget (@altcraft/target)
└─ static sendTarget(options: MobileEventOptions): void

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;
};

Use the sendTarget() function of the Target module to register a mobile event.


sid: string

Required: Yes
Description: String pixel identifier the mobile events are bound to.


eventName: string

Required: Yes
Description: Mobile event name.


sendMessageId: string | null

Required: No
Description: SMID identifier of the sent message if the event is related to a specific mailing.


payload: Record<string, unknown> | null

Required: No
Description: Event data — an object with string keys. Pass JSON-compatible values: string, number, boolean, objects, arrays and null.

Note

Non-serializable objects may be converted to a string or dropped by the native part, so use only JSON-compatible data for a stable result.


matching: Record<string, unknown> | null

Required: No
Description: Object with matching data, for example { email: 'ivan.petrov@example.com' }.


matchingType: string | null

Required: No
Description: Matching type.


profileFields: Record<string, unknown> | null

Required: No
Description: Profile fields.

Note

The profileFields parameter is used in scenarios where the profile is identified through JWT authorization and matching.


subscription: Subscription | null

Required: No
Description: Subscription to the selected channel. Created by the emailSubscription(), smsSubscription(), pushSubscription() or ccDataSubscription() factory function.

type Subscription =
| EmailSubscription
| SmsSubscription
| PushSubscription
| CcDataSubscription;

Common subscription fields (for all types)

FieldTypeRequiredDescription
type'email' | 'sms' | 'push' | 'cc_data'YesChannel type. Set by the factory function.
resourceIdnumberYesSubscription resource/source identifier.
statusstring?NoSubscription status.
prioritynumber?NoDelivery priority.
customFieldsRecord<string, unknown>?NoCustom subscription fields.
catsstring[]?NoSubscription categories.

Subscription variants

Email subscription (type = 'email')

FieldTypeRequiredDescription
resourceIdnumberYesAltcraft resource ID
emailstringYesEmail address
const emailSub = emailSubscription({
resourceId: 10,
email: 'user@example.com',
status: 'subscribed',
priority: 1,
customFields: { source: 'rn_app' },
cats: ['promo', 'news'],
});

SMS subscription (type = 'sms')

FieldTypeRequiredDescription
resourceIdnumberYesAltcraft resource ID
phonestringYesPhone number in international format
const smsSub = smsSubscription({
resourceId: 10,
phone: '+790****4567',
status: 'subscribed',
});

Push subscription (type = 'push')

FieldTypeRequiredDescription
resourceIdnumberYesAltcraft resource ID
providerstringYesProvider (for example, 'android-firebase')
subscriptionIdstringYesUnique subscription identifier at the provider
const pushSub = pushSubscription({
resourceId: 10,
provider: 'android-firebase',
subscriptionId: 'provider-sub-id',
status: 'subscribed',
priority: 1,
customFields: { source: 'rn_app' },
cats: ['promo', 'news'],
});

CcData subscription (type = 'cc_data')

FieldTypeRequiredDescription
resourceIdnumberYesAltcraft resource ID
channelstringYesCustom channel name, for example telegram_bot
ccDataRecord<string, unknown>YesChannel-specific data (chat ID, number, tokens)
const ccSub = ccDataSubscription({
resourceId: 10,
channel: 'telegram_bot',
ccData: { chat_id: '123456' },
});
Note

If the required fields of the selected channel are not filled in, the native bridge cannot build the subscription model and sends the mobile event without it.


utm: UTM | null

Required: No
Description: UTM tags.

type UTM = {
source?: string | null;
medium?: string | null;
campaign?: string | null;
content?: string | null;
keyword?: string | null;
temp?: string | null;
};
AltcraftSDK.sendTarget({
sid: 'pixel-000000000000000000000000',
eventName: 'app_install',
utm: {
campaign: 'summer_campaign',
content: 'main_banner',
keyword: 'mobile_sdk',
medium: 'push',
source: 'rn_app',
temp: 'a1',
},
});

Usage examples

Simple event

AltcraftSDK.sendTarget({
sid: 'pixel-000000000000000000000000',
eventName: 'app_open',
});

Passing data via payload

AltcraftSDK.sendTarget({
sid: 'pixel-000000000000000000000000',
eventName: 'purchase',
payload: {
orderId: 'A-1001',
amount: 3990,
currency: 'RUB',
items: [{ sku: 'sku-1', qty: 2 }],
},
});

Passing matching / matchingType

AltcraftSDK.sendTarget({
sid: 'pixel-000000000000000000000000',
eventName: 'profile_update',
payload: { source: 'settings' },
matching: { email: 'ivan.petrov@example.com' },
matchingType: 'email',
});

Passing subscription (JWT)

import { AltcraftSDK, pushSubscription } from '@altcraft/react-native-sdk';

AltcraftSDK.sendTarget({
sid: 'pixel-000000000000000000000000',
eventName: 'jwt_bind_subscription',
subscription: pushSubscription({
resourceId: 10,
provider: 'android-firebase',
subscriptionId: 'provider-sub-id',
status: 'subscribed',
}),
});

Receiving SDK events in the application​


In React Native SDK events are delivered to JavaScript through the native NativeEventEmitter. The handler receives an SdkEvent object:

type SdkEvent = {
function: string;
code: number | null;
message: string;
type: 'event' | 'error' | 'retryError';
value?: Record<string, unknown> | null;
timestamp?: string | null;
};

Event types:

  • event — informational events and successful operations;
  • error — execution errors;
  • retryError — errors of operations the SDK retries automatically.

Event fields:

  • function — name of the SDK function that raised the event;
  • message — event message, the main event identifier;
  • code — HTTP response code if the event is related to a network request;
  • value — additional data, for example response_with_http_code;
  • timestamp — timestamp in yyyy-MM-dd HH:mm:ss.SSS format.
Important

Events are no longer identified by numeric codes. Rely on message and the event type, and use the moduleEvents catalog constants of the corresponding module for comparisons — they account for message differences between Android and iOS.


Subscribing to events​

subscribeToEvents(handler) subscribes a handler to native SDK events. Several handlers can listen to the same event source.

import { AltcraftSDK, type SdkEvent } from '@altcraft/react-native-sdk';

const handler = (event: SdkEvent) => {
switch (event.type) {
case 'event':
console.log('SDK event:', event.message);
break;
case 'error':
console.log('SDK error:', event.message);
break;
case 'retryError':
console.log('SDK retry error:', event.message);
break;
}
};

AltcraftSDK.subscribeToEvents(handler);

Unsubscribing from events​

AltcraftSDK.unsubscribeFromEvents(handler);

A specific handler is unsubscribed — pass the same function you used for the subscription.


SDK error handling​

The modules throw AltcraftException on native call errors:

class AltcraftException extends Error {
readonly code: string;
}

Check code: ALTCRAFT_INIT_INVALID_CONFIG, ALTCRAFT_INIT_ERROR, SDK_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}`);
}
}

Full list of SDK events​

Event messages are grouped by module: AltcraftCore.moduleEvents, AltcraftPush.moduleEvents, AltcraftInApp.moduleEvents, AltcraftTarget.moduleEvents, AltcraftProfile.moduleEvents. The catalog of each module merges the messages of both platforms: a key that exists on only one platform keeps that platform's message and never matches on the other platform. Compare event.message with the constants, not with string literals. The "Platform" column shows on which platform the message is available; "—" means the message is the same on Android and iOS.

Core — AltcraftCore.moduleEvents
ConstantMessagePlatform
configIsSetSDK configuration is installedAndroid
sdkClearedSDK data has been cleared—
notAuthenticatedErrorUser is not authenticatedAndroid
notAuthenticatedErroruser is not authenticatediOS
userLogOutUser logged out. Anonymous session started.Android
userLogOutUser logged out. Anonymous session startediOS
roomMigrationErrorRoom database migration failed. The local SDK database will be recreated.Android
authenticateSuccessfulsuccessful request: profile/authenticate—
pushStatusRequestFailedfailed request: push/statusAndroid
configSetSDK configuration is installed.iOS
rTokenChangeRole token change: SDK database data will be cleared, except for configuration data.iOS
initAwaitwaiting for SDK initialization to completeiOS
backgroundTaskRegisterSDK background task is registerediOS
backgroundTaskCompletedSDK background task completediOS
configIsNotSetthe configuration is not setiOS
coreDataErrorerror in CoreData. Re-initialize the SDK.iOS
errorLoadModelInCoreDatafailed to load model from framework.iOS
appGroupIsNotSetApp Group name was not set.iOS
contextIsUnavailablecore data context is unavailableiOS
invalidCoreDataEntityNamethe coreData entity name is not validiOS
entityNotFoundByIDentity not found by IDiOS
coreDataModelNotFoundInBundleCore Data model was not found in any bundleiOS
coreDataModelMissingEntityCore Data model is missing the required entity; the model did not loadiOS
sdkInitWaitingExpiredSDK initialization timeout has expirediOS
invalidUrlValueinvalid apiUrl value - empty or null.iOS
invalidRTokenValueinvalid resource token value - resource token is empty.iOS
nonJsonObjectnon-json object has been providediOS
fieldsIsObjectsinvalid values: not all values are primitivesiOS
configIsNilconfig data is niliOS
userTagIsNiluserTag is null. It is impossible to identify the useriOS
permissionDeniednotification permission denied.iOS
backgroundTaskExpiredSDK background task expirediOS
jwtIsNilJWT token is niliOS
jwtParsingErrorJWT parsing erroriOS
externalAuthDataIsNilexternal auth data is niliOS
internalAuthDataIsNilinternal auth data is niliOS
failedCreateRequestFailed to create request.iOS
failedProcessingResponseFailed processing the responseiOS
responseDataIsNullresponse data is nulliOS
invalidRequestUrlinvalid request urliOS
invalidResponseFormatinvalid response formatiOS
authenticateFailedfailed request: profile/authenticateiOS
Push — AltcraftPush.moduleEvents
ConstantMessagePlatform
invalidProviderInvalid push configuration: unsupported push provider. Available providers: android-firebase, android-huawei, android-rustore.Android
configIsNullpush configuration is nullAndroid
invalidCustomFieldsinvalid custom fields: not all values are primitivesAndroid
eventRetryLimitpush event retry limitAndroid
eventRequestDataIsNullpush event request data is nullAndroid
eventRequestSuccessfulsuccessful request: event/pushAndroid
eventRequestFailedfailed request: event/pushAndroid
pushUidIsNullpush uid is nullAndroid
subscribeRetryLimitpush subscribe retry limitAndroid
subscribeRequestDataIsNullpush subscribe request data is nullAndroid
subscribeRequestSuccessfulsuccessful request: push/subscribeAndroid
subscribeRequestFailedfailed request: push/subscribeAndroid
suspendRequestSuccessfulsuccessful request: push/suspendAndroid
suspendRequestFailedfailed request: push/suspendAndroid
unsubscribeRequestSuccessfulsuccessful request: push/unsubscribeAndroid
unsubscribeRequestFailedfailed request: push/unsubscribeAndroid
tokenUpdateRequestDataIsNulltoken update request data is nullAndroid
tokenUpdateRequestSuccessfulsuccessful request: push/update—
tokenUpdateRequestFailedfailed request: push/update—
pushTokenIsNullpush token is nullAndroid
notUpdatedpush token not updatedAndroid
pushProviderSetpush provider set -Android
pushProviderSetpush provider set:iOS
invalidPushProviderInvalid push provider. Available providers: android-firebase, android-huawei, android-rustore.Android
invalidPushProviderinvalid provider.iOS
statusRequestDataIsNullsubscription status request data is nullAndroid
statusRequestSuccesssuccessful request: push/statusAndroid
statusRequestFailedfailed request: push/statusAndroid
unSuspendRequestDataIsNullunsuspend request data is nullAndroid
unSuspendRequestSuccessfulsuccessful request: push/unsuspendAndroid
unSuspendRequestFailedfailed request: push/unsuspendAndroid
pushDataIsNullpush data is nullAndroid
notificationErrnotification errorAndroid
channelNotCreatednotification channel not createdAndroid
pushPermissionDeniednotification permission deniedAndroid
pushIsPostedpush notification is postedAndroid
pushIsPostedpush is posted.iOS
acPushAltcraft push notification receivedAndroid
notAcPushreceived a notification unrelated to the Altcraft PlatformAndroid
duplicatePushMessageduplicate push message: processing and display skippedAndroid
duplicatePushMessageduplicate push message, uid:iOS
receiverRedefinedpush receiver redefinedAndroid
errorImgLoaderror loading push imageAndroid
successImgLoadpush image loaded successfullyAndroid
pushReceivereceived Altcraft push notification.iOS
pushTokenUpdateAwaitwaiting for push token update to completeiOS
apnsIsNotUpdatedforcing a push token update is not possible: the operation is not supported for APNs.iOS
errorHandleUserInfoinvalid userInfo formatiOS
uidIsNiluid in the push data is null, it is impossible to send a push event to the server.iOS
errorMediaDownloadcould not download image data from URL.iOS
errorMediaKeyMissing'media' key is missing or URL string is invalid.iOS
errorButtonsKeyMissing'buttons' key is missing or is invalid.iOS
invalidButtonIdentifierinvalid button identifier. See event valueiOS
outOfRangeForIdentifierout of range for identifier. See event valueiOS
unknownButtonIdentifierunknown button identifier. See event valueiOS
invalidPushProvidersinvalid provider. Available - ios-apns, ios-firebase, ios-huawei.iOS
pushTokenIsNilcurrent push token is niliOS
subscribeRequestDataIsNilsubscribe request data is niliOS
updateRequestDataIsNilupdate request data is niliOS
pushEventRequestDataIsNilpush event request data is niliOS
unsuspendRequestDataIsNilunsuspend request data is niliOS
pushStatusRequestDataIsNilpush status request data is niliOS
invalidSubRequestDatainvalid push subscribe request dataiOS
invalidPushEventRequestDatainvalid push event request dataiOS
pushConfigurationSaveFailedfailed to save the push configuration to the local databaseiOS
pushConfigurationClearFailedfailed to clear the push configuration from the local databaseiOS
pushUnsubscribeRequestSuccessfulsuccessful request: push/unsubscribeiOS
pushSubscribeRequestSuccessfulsuccessful request: push/subscribeiOS
pushSuspendRequestSuccessfulsuccessful request: push/suspendiOS
pushStatusRequestSuccessfulsuccessful request: push/statusiOS
pushEventRequestSuccessfulsuccessful request: event/pushiOS
unsuspendRequestSuccessfulsuccessful request: push/unsuspendiOS
pushUnsubscribeRequestFailedfailed request: push/unsubscribeiOS
pushSubscribeRequestFailedfailed request: push/subscribeiOS
pushSuspendRequestFailedfailed request: push/suspendiOS
pushStatusRequestFailedfailed request: push/statusiOS
pushEventRequestFailedfailed request: event/pushiOS
unsuspendRequestFailedfailed request: push/unsuspendiOS
In-App — AltcraftInApp.moduleEvents
ConstantMessagePlatform
maxPlacementsInvalidInvalid in-app configuration: maxPlacements must be >= 1—
requestIntervalInvalidInvalid in-app configuration: placementsRequestInterval must be >= 15 minutesAndroid
requestIntervalInvalidInvalid in-app configuration: placementsRequestInterval must be > 0iOS
subscribeRetryLimitin-app subscribe retry limitAndroid
subscribeRequestDataIsNullin-app subscribe request data is nullAndroid
subscribeRequestSuccessfulsuccessful request: inapp/subscribeAndroid
subscribeRequestFailedfailed request: inapp/subscribeAndroid
unsubscribeRequestSuccessfulsuccessful request: inapp/unsubscribeAndroid
unsubscribeRequestFailedfailed request: inapp/unsubscribeAndroid
invalidCustomFieldsinvalid custom fields: not all values are primitivesAndroid
statusRequestDataIsNullin-app status request data is nullAndroid
statusRequestSuccessfulsuccessful request: inapp/statusAndroid
statusRequestFailedfailed request: inapp/statusAndroid
eventRetryLimitin-app event retry limitAndroid
eventRequestDataIsNullin-app event request data is nullAndroid
smidIsNullsend message ID is nullAndroid
eventRequestSuccessfulsuccessful request: inapp/eventAndroid
eventRequestFailedfailed request: inapp/eventAndroid
placementsRequestDataIsNullin-app placements request data is nullAndroid
placementsRequestSuccessfulsuccessful request: inapp/placementsAndroid
placementsRequestFailedfailed request: inapp/placementsAndroid
placementsLimitExceededin-app placements limit exceeded—
inAppCanShowFailedin-app was not shown because a display policy check failed:Android
invalidStaticFieldinvalid in-app static field—
inAppStaticErrorLoaderror loading in-app notification static resources—
inAppContentErrorLoaderror loading in-app notification content—
errorInAppImageLoadfailed to load in-app imageiOS
smidIsNilsmid in the in-app data is null, it is impossible to send a in-app event to the server.iOS
acidIsNilacid in the in-app data is null, it is impossible to send a in-app event to the server.iOS
inAppStatusRequestDataIsNilin-app status request data is niliOS
inAppEventRequestDataIsNilin-app event request data is niliOS
subscribeRequestDataIsNilin-app subscribe request data is niliOS
invalidSubRequestDatainvalid in-app subscribe request dataiOS
inAppUnsubscribeRequestSuccessfulsuccessful request: inapp/unsubscribeiOS
inAppSubscribeRequestSuccessfulsuccessful request: inapp/subscribeiOS
inAppStatusRequestSuccessfulsuccessful request: inapp/statusiOS
inAppEventRequestSuccessfulsuccessful request: inapp/eventiOS
inAppPlacementsRequestSuccessfulsuccessful request: inapp/placementsiOS
inAppUnsubscribeRequestFailedfailed request: inapp/unsubscribeiOS
inAppPlacementsRequestFailedfailed request: inapp/placementsiOS
inAppSubscribeRequestFailedfailed request: inapp/subscribeiOS
inAppStatusRequestFailedfailed request: inapp/statusiOS
inAppEventRequestFailedfailed request: inapp/eventiOS
Target — AltcraftTarget.moduleEvents
ConstantMessagePlatform
partsIsNulltarget request parts is nullAndroid
retryLimittarget request retry limitAndroid
invalidPayloadinvalid target payload: not all values are primitivesAndroid
requestDataIsNulltarget request data is nullAndroid
requestSuccessfulsuccessful target request: event/postAndroid
requestFailedfailed target request: event/postAndroid
mobileRequestDataIsNilmobile event request data is niliOS
mobileEventRequestSuccessfulsuccessful request: event/postiOS
mobileEventRequestFailedfailed request: event/postiOS
Profile — AltcraftProfile.moduleEvents
ConstantMessagePlatform
requestDataIsNullprofile update request data is nullAndroid
retryLimitprofile update retry limitAndroid
requestSuccessfulsuccessful request: profile/updateAndroid
requestFailedfailed request: profile/updateAndroid
profileUpdateRequestDataIsNilprofile update request data is niliOS
profileUpdateRequestSuccessfulsuccessful request: profile/updateiOS
profileUpdateRequestFailedfailed request: profile/updateiOS

Authentication​


AltcraftCore (@altcraft/core)
├─ static setJwtProvider(provider: () => Promise<string | null>): void
├─ static authenticate(): void
├─ static logOut(): void
└─ static isAuthenticated(): Promise<boolean>

setJwtProvider(provider)

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. Register the provider before calling initialize().

AltcraftSDK.setJwtProvider(async () => await myBackend.getJwtToken());

authenticate()

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. Call it after the user logs in to the application.

The result arrives as the events successful request: profile/authenticate (AltcraftCore.moduleEvents.authenticateSuccessful) and failed request: profile/authenticate.

AltcraftSDK.authenticate();

logOut()

Ends the user session: the SDK clears the profile data and starts an anonymous session. The event is AltcraftCore.moduleEvents.userLogOut.

AltcraftSDK.logOut();

isAuthenticated()

Returns true if the SDK is authenticated and works with the user profile.

const isAuthenticated = await AltcraftSDK.isAuthenticated();
Note

In profile switching scenarios JWT authentication is combined with unSuspendPushSubscription(): when logging into a profile after authenticate(), the suspended subscription is restored and the subscription of the previous profile is suspended. See Changing the subscription status for details.


ActionFieldBuilder​


The SDK provides ActionFieldBuilder for structured management of profile fields. The builder produces an object compatible with the native SDK, which should be merged with profileFields before passing it to pushSubscribe, updateProfileFields or a mobile event.

import { actionField } from '@altcraft/core';

const profileFields = {
...actionField('_fname').set('Ivan'),
...actionField('_lname').set('Petrov'),
...actionField('login_count').incr(1),
...actionField('visited_pages').add('/settings'),
...actionField('old_field').unset(null),
};

AltcraftSDK.updateProfileFields({ profileFields, skipTriggers: false });
MethodDescription
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.

Additional SDK functions​


Clearing SDK data​

await AltcraftSDK.clear();

The function clears SDK data and cancels all background tasks awaiting execution.


Manual registration of push events​

Note

These functions apply only if you implement your own notification handling logic and do not pass notifications to the SDK automatically.

type PushEventOptions = {
message?: Record<string, string> | null;
messageUID?: string | null;
};

Android​

  • deliveryEvent({ message, messageUID }) — registers notification delivery;
  • openEvent({ message, messageUID }) — registers notification opening.
AltcraftSDK.deliveryEvent({
message: { _uid: 'push-message-uid-0001', _provider: 'android-firebase' },
messageUID: 'push-message-uid-0001',
});

AltcraftSDK.openEvent({
message: { _uid: 'push-message-uid-0001', _provider: 'android-firebase' },
messageUID: 'push-message-uid-0001',
});

Passing rules:

  • you can pass only message (the SDK takes the message identifier from the payload if it is present there);
  • you can pass only messageUID (if the payload is unavailable but the identifier is known);
  • if both parameters are missing, the event is not registered correctly (there is no data to identify the message).

iOS​

Manual registration of push events is not implemented on the React Native side: the deliveryEvent() and openEvent() calls on iOS are no-ops. If manual event registration is required, perform it in the native part of the application.

See the iOS instructions.


Updating profile fields​

AltcraftSDK.updateProfileFields({
profileFields?: Record<string, unknown> | null,
skipTriggers?: boolean | null,
});

The function updates profile fields on the server.

  • profileFields — object of profile fields to update.
  • skipTriggers — when the flag is enabled, the profile is ignored in mailing and scenario triggers.
AltcraftSDK.updateProfileFields({
profileFields: { _fname: 'Ivan', _lname: 'Petrov' },
skipTriggers: false,
});

Forced token update​

await AltcraftSDK.forcedTokenUpdate();

The function starts a forced push token update.


Deleting the device token​

await AltcraftSDK.deleteDeviceToken('android-firebase');

The function deletes the device token for the specified provider.


Changing the push provider priority​

await AltcraftSDK.changePushProviderPriorityList([
'android-firebase',
'android-huawei',
'android-rustore',
]);

The function changes the push provider priority list for the application runtime. The initial list is set in pushConfig({ providerPriority: [...] }) at SDK initialization.


Checking an Altcraft push​

const isAltcraft = AltcraftSDK.isAltcraftPush({
_ac_push: 'Altcraft',
_uid: 'push-message-uid-0001',
});

The function checks whether the push message belongs to Altcraft. Returns true if the message belongs to Altcraft and false otherwise. On iOS the method always returns false.


Unlocking initial operations in the session​

AltcraftSDK.unlockInitialOperationsInThisSession();

The function unlocks initial operations in the current session. The method is used on Android. On iOS the call is a no-op.


App Group and UserDefaults​

AltcraftSDK.setAppGroup(groupName: string | null): void
AltcraftSDK.setUserDefaultsValue(
suiteName: string | null,
key: string,
value: string | null
): void
  • setAppGroup() — used on iOS to set the App Group that defines the UserDefaults space shared between the main application and the Notification Service Extension. On Android the method is a no-op. On iOS groupName must not be null.
  • setUserDefaultsValue() — stores a string value in native storage: UserDefaults on iOS and SharedPreferences on Android. If value === null, the key is deleted. On Android suiteName is ignored.
import { Platform } from 'react-native';
import { AltcraftSDK } from '@altcraft/react-native-sdk';

if (Platform.OS === 'ios') {
const appGroup = 'group.altcraft.rn.example';

AltcraftSDK.setAppGroup(appGroup);
AltcraftSDK.setUserDefaultsValue(appGroup, 'altcraft_jwt', jwtToken);
}
Last updated on Nov 26, 2026
Previous
SDK configuration
Next
Public SDK API
  • Working with subscription statuses
    • Changing the subscription status
    • Requesting the subscription status
  • Managing provider push tokens
  • Registering and passing push notifications to the SDK
    • In native code
    • In React Native
  • In-App notifications
    • Subscribing to In-App notifications
    • Showing In-App campaigns
    • In-App campaign display animation
    • Campaigns with JSON content
  • Mobile events
  • Receiving SDK events in the application
    • Subscribing to events
    • Unsubscribing from events
    • SDK error handling
    • Full list of SDK events
  • Authentication
  • ActionFieldBuilder
  • Additional SDK functions
    • Clearing SDK data
    • Manual registration of push events
      • Android
      • iOS
    • Updating profile fields
    • Forced token update
    • Deleting the device token
    • Changing the push provider priority
    • Checking an Altcraft push
    • Unlocking initial operations in the session
    • App Group and UserDefaults
© 2015 - 2026 Altcraft, LLC. All rights reserved.