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.swift
override func application(
    _ application: UIApplication,
    didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
  ) -> Bool {
    GeneratedPluginRegistrant.register(with: self)
        SentianceCorePlugin.shared.initialize()
        return super.application(application, didFinishLaunchingWithOptions: launchOptions)
  }

Android

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

...
import com.sentiance.core_plugin.CorePlugin
...

class MainApplication : FlutterApplication() {

    @Override
    public void onCreate() {
        super.onCreate();
        ...
        
        CorePlugin.initialize(this);
    }

  ...
}

Last updated