Skip to content

Initializing the SDK

ForstaMobileApp edited this page Sep 9, 2022 · 1 revision

To use the SDK in your app, you must initialize it. This only has to be done once.

Android

Because the SDK requires Application, the recommended place to initialize the SDK will be onCreate on application subclass:

NOTE: The SDK is fully built with Kotlin. You will see more Kotlin Interop classes / functions during implementation. Check more detail on Kotlin Interop.

class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()

        ConfirmitSDK.Setup(this).configure()
        
        // Initialize server with received Client ID and Client Secret keys
        ConfirmitServer.configureUK("<Client ID>", "<Client Secret>")
    }
}

If you create your own application subclass, you must add it to the app’s AndroidManifest.xml:

<application
  android:name=".MyApplication"
  ...
/>

iOS

Recommended place to initialize SDK will be application(_:didFinishLaunchingWithOptions:) on AppDelegate class.

import MobileSurveySdk

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    ...

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

        ConfirmitSDK.Setup().configure()

        // Initialize server with received Client ID and Client Secret keys
        try! ConfirmitServer.configureUK(clientId: "<Client ID>", clientSecret: "<Client Secret>")
        
        return true
    }
}

Clone this wiki locally