3. Initialization

Initialization sets up internal SDK components to allow the creation of a Sentiance user on the device, and perform detections in the background.

Only a limited set of SDK functions are allowed to be invoked before initializing the SDK.

iOS

The correct way to natively initialize on iOS is to do it inside the application:didFinishLaunchingWithOptions: method of the AppDelegate class.

AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    SENTInitializationResult *result = [[[RNSentianceHelper alloc] init] initializeSDKWithLaunchOptions:launchOptions];
    return YES;
}

Initialization will normally succeed unless an unexpected error or exception is encountered. In case of failure, you can check the reason via the returned result.

if (result.isSuccessful) {
    NSLog(@"Initialization succeeded");
}
else {
    NSLog(@"Initialization failed with reason %lu", result.failureReason);
}

Android

Add the following code inside the onCreate() method of your Application class:

Initialization will normally succeed, unless an unexpected error or exception is encountered. In case of failure, you can check the reason via the returned result.

Last updated