React Native SDK Methods

📘

Initialization

Mindbox.initialize

Configuring and initializing the SDK

MindboxSdk.initialize({
        domain: 'domain API mindbox',
        endpointId:
          Platform.OS === 'ios'
            ? '<ios endpoint>'
            : '<android endpoint>',
        subscribeCustomerIfCreated: true,
        shouldCreateCustomer: true,
        previousInstallId: '',
        previousUuid: '',
      })
📘

Mindbox’s API Domain

The domain used to send requests to Mindbox’s API.
Possible values:

  • api.mindbox.ru is selected when the project address is project.mindbox.ru
  • api.mindbox.cloud is selected when the project address is project.mindbox.cloud

❗️Don't submit your Project control panel’s address here

Obtaining data from the SDK

getDeviceUUID

Method to retrieve device UUID after assignment. Can be called anytime but will only return a string in the callback after initialization.

MindboxSdk.getDeviceUUID(uuid => {
    console.log(uuid);
  });

getToken

Method to retrieve token (APNS/FCM) after assignment. Can be called anytime but will only return a string in the callback after initialization.

MindboxSdk.getToken(token => {
    console.log(token);
  });

Handling notification clicks

onPushClickReceived

Method to subscribe to notification click events. The callback is triggered when a user clicks a notification and the app launches.
It receives the URL embedded in the clicked push notification as an argument.
Returns button URL when clicking a button; returns body URL when clicking the notification body.

MindboxSdk.onPushClickReceived((pushUrl: String | null, pushPayload: String | null) => { 
  console.log(pushUrl);
  console.log(pushPayload);
});

Sending events (calling operations)

To pass events to Maestra, use the operations added to the admin panel of your project. You can run these operations in two modes:

  • async mode — once Maestra receives data, Mindbox's API returns the 200 status, and then processes data in the background,
  • sync mode — Mindbox's API starts processing the call the moment it receives it and responds with the relevant processing status.

executeAsyncOperation

Call this method to execute async operations.

MindboxSdk.executeAsyncOperation({
  operationSystemName: '<method system name>',
  operationBody: { <JS object with data> },
});

executeSyncOperation

Call this method to execute synced operations. The results are returned via callbacks.

MindboxSdk.executeSyncOperation({
  operationSystemName: '<method system name>',
  operationBody: { <JS object with data> },
  onSuccess: (data) => { ... },
  onError: (error) => { ... },
});

getSdkVersion (since 2.8.0)

Method to get current SDK version

import MindboxSdk from "mindbox-sdk";

MindboxSdk.getSdkVersion((version) => { ... })

setLogLevel (since 2.8.0)

To control the Mindbox SDK's console output, use the dedicated log level method: setLogLevel.
Logs are written in a debug build only. In production mode, Mindbox SDK doesn't log anything to the console.

import MindboxSdk, { LogLevel} from "mindbox-sdk";

MindboxSdk.setLogLevel(LogLevel.DEBUG)

LogLevel Values:

  • LogLevel.VERBOSE
  • LogLevel.DEBUG
  • LogLevel.INFO
  • LogLevel.WARN
  • LogLevel.ERROR
  • LogLevel.NONE

updateNotificationPermissionStatus (since 2.8.0)

Method to update notification permission status. Call after receiving user's notification permission to immediately update status in Mindbox SDK.

import MindboxSdk from "mindbox-sdk";

MindboxSdk.updateNotificationPermissionStatus(true);