For the complete documentation index, see llms.txt. This page is also available as Markdown.

iOS

Initialization allows the SDK to perform detections in the background. You must always initialize the SDK before interacting with it. Only a limited set of SDK methods are safe to invoke on an uninitialized SDK.

Steps

1

Create an AppDelegate Class

Initialization must be done in the application:didFinishLaunchingWithOptions: method of your AppDelegate class. If you don't already have a custom AppDelegate set up, first create a new class that extends UIApplicationDelegate.

UIKit app
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        true
    }
}
SwiftUI app
class AppDelegate: NSObject, UIApplicationDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {        
        return true
    }
}

struct MyApp: App {
    @UIApplicationDelegateAdaptor(AppDelegate.self) var appDelegate

    var body: some Scene {
        ..
    }
}
2

Initialize the SDK

In the application:didFinishLaunchingWithOptions: method of your AppDelegate class, call initializeAsync().

import SENTSDK

class AppDelegate: NSObject, UIApplicationDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

        let options = SENTOptions(for: .appLaunch)
        Sentiance.shared.initializeAsync(options: options, launchOptions: launchOptions) { result, error in
            if let result {
                NSLog("Initialization succeeded")
            }
            else if let error {
                NSLog("Initialization failed with reason \(error.failureReason)")
            }
        }
        
        return true
    }
}
3

Next: User Creation

After having successfully initialized the Sentiance SDK, you must now create a user. To do so, follow the instructions on this page.

Last updated