Quick Start
This article provides an example of quick integration of Altcraft mSDK for React Native.
Step 0. Prerequisites
-
A React Native project is created and runs on iOS/Android.
-
Native push providers are integrated into the project:
-
Altcraft mSDK is configured on the native side:
- providers are registered (JWT / APNS / FCM / HMS / RuStore);
- interception of incoming push notifications and their forwarding to the SDK is configured.
Step 1. Package installation
npm i @altcraft/react-native-sdk
# or
yarn add @altcraft/react-native-sdk
Step 2. SDK configuration and initialization
Import the SDK and initialize it at app startup (for example, in App.tsx):
import AltcraftSDK from '@altcraft/react-native-sdk';
AltcraftSDK.initialize({
apiUrl: 'https://pxl-your-instance.altcraft.com',
rToken: null,
appInfo: {
appID: 'your-app-id',
appIID: 'your-installation-id',
appVer: '1.0.0',
},
providerPriorityList: null,
enableLogging: true,
// -------- ANDROID-ONLY (optional) --------
android_icon: null,
android_pushReceiverModules: null,
android_pushChannelName: null,
android_pushChannelDescription: null,
});
Step 3. Subscribing to push notifications
Push subscription is performed by calling pushSubscribe():
import AltcraftSDK from '@altcraft/react-native-sdk';
AltcraftSDK.pushSubscribe(
true,
{ _fname: 'user_first_name', _lname: 'user_last_name' }, // profileFields
null, // customFields
null, // cats
null, // replace
null // skipTriggers
);
sync: true— performs the request synchronously (the result can be obtained via an SDK event if supported by the platform).sync: false— performs the request asynchronously.