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 configuration

SDK configuration

The SDK is built on a modular principle: the core (Core) is responsible for initialization, authorization and events, while the Push, In-App, Target and Profile modules are connected as separate npm packages. The @altcraft/react-native-sdk package contains the entire SDK API on top of the modules.

Prerequisites​

  • The React Native 0.75+ project runs on Android 7.1+ (API 25) and iOS 13.0+.
  • The SDK packages are added to the project:
PackageModulePurpose
@altcraft/react-native-sdk—Wrapper package with the entire SDK API on top of the modules
@altcraft/coreCoreInitialization, authorization, events, data clearing
@altcraft/pushPushSubscription, push tokens, notification handling
@altcraft/inappIn-AppIn-App campaigns, placements, animations
@altcraft/targetTargetMobile events, UTM tags
@altcraft/profileProfileProfile field updates
  • Push notification provider SDKs are integrated into the application project.
  • If API requests must be authorized via JWT, a JWT provider is implemented (see Passing the JWT token to the SDK).

Installing the wrapper package with the entire SDK:

yarn add @altcraft/react-native-sdk
# or
npm i @altcraft/react-native-sdk

Installing individual modules (the @altcraft/core package must be specified as a direct dependency — the other modules are built on it):

yarn add @altcraft/core @altcraft/push @altcraft/inapp @altcraft/target @altcraft/profile

After installing the native modules, rebuild the application:

cd ios && pod install && cd ..
npm run android
# or
npm run ios
Important

The AltcraftConfigBuilder.pushConfig() and AltcraftConfigBuilder.inAppConfig() methods are available only if the corresponding module package is imported into the file with the initialization. This mirrors the logic of native module linking.

Preparing the application​

Passing the JWT token to the SDK (optional)​

A JWT implementation is required if JWT authentication of API requests is used. The JWT confirms that user identifiers are authenticated by the application.

A JWT authentication implementation is mandatory if a matching type other than push data from the subscription is used (for example, the user identifier is an email or a phone number).

In the React Native SDK the JWT provider is registered with the setJwtProvider() method:

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

AltcraftSDK.setJwtProvider(async () => {
// Return the current JWT token of the user.
// The provider may be called on every request that requires authorization.
return await myBackend.getJwtToken();
});

Rules for working with the JWT provider:

  • the provider is registered before the initialize() call and before the first operation that requires authorization;
  • the native side requests the token from the application at the moment a request is executed, so the provider must return a current value rather than one cached for the entire lifetime of the application;
  • if the provider returns null, the SDK fails the request with an authorization error (the event "JWT token is null" / "JWT token is nil").

The authenticate() and logOut() methods are used to log the user in and out:

// Start the user session with the current JWT
AltcraftSDK.authenticate();

// End the session: the SDK clears the profile data and starts an anonymous session
AltcraftSDK.logOut();

// Check whether the user is authenticated
const isAuthenticated = await AltcraftSDK.isAuthenticated();

Preparing to work with push providers​

Push providers are configured on the native side of the application.

Android:

  • Connecting FCM
  • Connecting HMS
  • Connecting RuStore
  • Passing push notifications to the SDK

iOS:

  • Connecting APNS
  • Connecting FCM
  • Connecting HMS
  • Configuring the AppDelegate
  • Preparing the NSE
Important

The provider priority is set in the Push module configuration (pushConfig({ providerPriority: [...] })), not in the common SDK parameters. Connecting dependencies, services and handlers is performed in the native parts of the project.

SDK initialization​

Initialization parameters​

Configuration parameters are passed through an object of the AltcraftConfig type. Common parameters can be passed directly, but for module settings use AltcraftConfigBuilder: common parameters are passed to the constructor, module parameters are added by extension methods.

import { AltcraftConfigBuilder } from '@altcraft/core';
import '@altcraft/inapp';
import '@altcraft/push';

const config = new AltcraftConfigBuilder({
apiUrl: 'https://pxl-example.altcraft.com',
rToken: 'your-role-token',
appInfo: {
appID: 'your-app-id',
appIID: 'your-installation-id',
appVer: '1.0.0',
},
enableLogging: true,
})
.pushConfig({
providerPriority: ['android-firebase', 'android-huawei', 'android-rustore'],
})
.inAppConfig({
maxPlacements: 500,
})
.build();

Common parameters (AltcraftConfigBuilder / AltcraftConfig)

apiUrl string
Required: Yes
Description: Altcraft API endpoint URL.


rToken string | null
Default: null
Required: No
Description: Altcraft role token (identifies the resource/database/account). Used when the only matching type is the device push token.


appInfo AppInfo | null
Default: null
Required: No
Description: Basic application metadata.

FieldTypeDescription
appIDstringApplication identifier.
appIIDstringApplication installation identifier.
appVerstringApplication version.

enableLogging boolean | null
Default: null
Required: No
Description: Enables/disables logging.


moduleConfigs string | null
Default: null
Required: No
Description: Serialized module configurations by identifier (push, inapp). Produced by AltcraftConfigBuilder; the core passes the value to the native side without interpreting its content.


Push module parameters (pushConfig)

FieldTypePlatformDescription
providerPrioritystring[] | nullAndroid, iOSProvider priority list (by index: 0 is the highest priority).
iconnumber | nullAndroiddrawable resource ID used as the notification icon. Takes precedence over iconName.
iconNamestring | nullAndroidNotification icon resource name: looked up in drawable, then in mipmap.
pushReceiverModulesstring[] | nullAndroidList of package names containing native AltcraftPushReceiver implementations.
pushChannelNamestring | nullAndroidBase name of the push notification channel (visible in Android settings).
pushChannelDescriptionstring | nullAndroidPush channel description (visible in Android settings).

Example for Android:

.pushConfig({
providerPriority: ['android-firebase', 'android-huawei', 'android-rustore'],
iconName: 'ic_notification',
pushChannelName: 'Altcraft',
pushChannelDescription: 'Marketing notifications',
})

Example for iOS:

.pushConfig({
providerPriority: ['ios-apns', 'ios-firebase', 'ios-huawei'],
})

In-App module parameters (inAppConfig)

FieldTypeDefaultDescription
inAppAutoRequestbooleantrueAutomatically request In-App placements.
placementsRequestIntervalMsnumber30 minutesInterval between automatic placement requests in milliseconds. The native side applies a minimum value of 15 minutes.
maxPlacementsnumber500Maximum number of placements in local storage.
.inAppConfig({
inAppAutoRequest: true,
placementsRequestIntervalMs: 30 * 60 * 1000,
maxPlacements: 500,
})

Performing initialization​

Use the initialize(config) function to initialize the SDK:

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

await AltcraftSDK.initialize({
apiUrl: 'https://pxl-example.altcraft.com',
rToken: null,
enableLogging: true,
appInfo: {
appID: 'your-app-id',
appIID: 'your-installation-id',
appVer: '1.0.0',
},
});

If module settings are needed (push providers, In-App parameters), pass the configuration assembled by the builder to initialize():

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

await AltcraftSDK.initialize(
new AltcraftConfigBuilder({ apiUrl: 'https://pxl-example.altcraft.com' })
.pushConfig({ providerPriority: ['android-firebase'] })
.build()
);

Call order at application startup:

  1. setJwtProvider() — if JWT authentication is used.
  2. initialize(config) — once per application run.
  3. requestNotificationPermission() — on Android 13+ and on iOS, before the first subscription.
  4. pushSubscribe() — subscription to push notifications.

Requesting notification permission​

The permission is requested with the requestNotificationPermission() method:

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

const granted = await AltcraftSDK.requestNotificationPermission();
  • Android. The POST_NOTIFICATIONS runtime permission is requested for Android 13+. On earlier versions the method returns true immediately.
  • iOS. Authorization is requested through UNUserNotificationCenter (.alert, .badge, .sound).

The method returns true if the permission is granted.


Working with App Group and UserDefaults on iOS​

For iOS the SDK provides methods for setting the App Group and writing string values to UserDefaults. On Android setAppGroup() is a no-op, and setUserDefaultsValue() stores the value in the SDK SharedPreferences.

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);
// Token for the Notification Service Extension
AltcraftSDK.setUserDefaultsValue(appGroup, 'altcraft_jwt', jwtToken);
}
MethodDescription
setAppGroup(groupName: string | null)Sets the App Group, the UserDefaults space shared between the application and the NSE. On iOS groupName must not be null.
setUserDefaultsValue(suiteName: string | null, key: string, value: string | null)Stores a string value. value = null deletes the key. On Android suiteName is ignored.
Last updated on Nov 26, 2026
Previous
Quick start
Next
SDK functionality
  • Prerequisites
  • Preparing the application
    • Passing the JWT token to the SDK (optional)
    • Preparing to work with push providers
  • SDK initialization
    • Initialization parameters
    • Performing initialization
  • Requesting notification permission
  • Working with App Group and UserDefaults on iOS
© 2015 - 2026 Altcraft, LLC. All rights reserved.