SDK Configuration
Prerequisites
- Push provider SDKs are integraated into the app project (see the push provider integration guides).
- The npm package is installed from the repository npm using one of the following commands:
yarn add altcraft-react-native-sdk
# or
npm i altcraft-react-native-sdk
App preparation
Passing a JWT token to the SDK (optional)
JWT implementation is required if API requests use JWT authentication. JWT confirms that user identifiers are authenticated by the app.
JWT authentication is mandatory if the matching type differs from push data from the subscription (for example, when the user identifier is an email or phone number).
JWT setup follows the same approach as in the native SDKs (Android / iOS).
Preparing to work with push providers
For iOS, preparation for working with push providers is done natively. Detailed instructions are available in this section of the mSDK setup guide.
SDK initialization
Initialization parameters
Use the AltcraftConfig object to pass configuration parameters:
export type AltcraftConfig = {
apiUrl: string;
rToken?: string | null;
appInfo?: {
appID: string;
appIID: string;
appVer: string;
} | null;
providerPriorityList?: string[] | null;
enableLogging?: boolean | null;
// -------- ANDROID-ONLY --------
android_icon?: number | null;
android_usingService?: boolean | null;
android_serviceMessage?: string | null;
android_pushReceiverModules?: string[] | null;
android_pushChannelName?: string | null;
android_pushChannelDescription?: string | null;
};
Parameter descriptions:
apiUrl string
Required: Yes
Description: Altcraft API endpoint URL
rToken string | null
Default: null
Required: No
Description: Altcraft role token (identifies a resource / database / account). Used when the only matching type is the device push token.
appInfo { appID: string; appIID: string; appVer: string } | null
Default: null
Required: No
Description: Basic application metadata.
enableLogging boolean | null
Default: null
Required: No
Description: Enables or disables logging.
providerPriorityList string[] | null
Default: null
Required: No
Description: Provider priority list (by index: 0 is the highest priority).
Usage examples:
Android
providerPriorityList: ['android-firebase', 'android-huawei', 'android-rustore']
iOS
providerPriorityList: ['ios-apns', 'ios-firebase', 'ios-huawei']
android_icon number | null (Android only)
Default: null
Required: No
Description: drawable resource ID used as the notification icon.
android_pushReceiverModules string[] | null (Android only)
Default: null
Required: No
Description: List of package names containing native AltcraftPushReceiver implementations.
android_pushChannelName string | null (Android only)
Default: null
Required: No
Description: Base name of the push notification channel (visible in Android settings).
android_pushChannelDescription string | null (Android only)
Default: null
Required: No
Description: Push channel description (visible in Android settings).
android_usingService boolean | null (Android only)
Default: null
Required: No
Description: Enables the use of foreground services when subscribing and updating the push token.
android_serviceMessage string | null (Android only)
Default: null
Required: No
Description: Text shown in foreground service / background task notifications. If null, the SDK default value is used.
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',
// optional
rToken: null,
enableLogging: true,
providerPriorityList: ['android-firebase', 'android-huawei', 'android-rustore'],
// android-only (optional)
android_icon: null,
android_usingService: null,
android_serviceMessage: null,
android_pushReceiverModules: null,
android_pushChannelName: null,
android_pushChannelDescription: null,
});