Skip to main content

Initialize the SDK

To initialize the SDK, you need to provide an SdkConfig with your desired configuration.

SDK config builder​

The minimum viable SdkConfig is SdkConfig.Builder().build(), although the following configurations are also available:

ConfigurationMethodDefault
API environmentsetApiEnvironmentProduction
Cloud auth tokensetCloudAuthToken-
Cloud refresh tokensetCloudRefreshToken-
Fusion hostsetFusionHosthttp://localhost:27700
Secure storagesetSecureStorageOverride-
Debug LoggingsetDebugLoggingfalse
info
  • If you initialize the SDK without a cloud auth token, you will need to either provide one manually through the context manager or call the login function to access most SDK functionalities.
  • The SDK logs at info level by default. Enabling debug logging also prints the debug messages.

Secure storage​

By default, the SDK stores the context information on its own, as shown in the following table:

PlatformStorage
AndroidEncryptedSharedPreferences
JVMMemory
iOS / macOS / watchOSKeychain
JS BrowserLocalStorage
JS NodeMemory
C# / PythonMemory
info

To override the default secure storage, you must implement the SecureStorage interface and pass the class through the setSecureStorageOverride function from SdkConfig builder.

Initialize​

Initialization sets up the HTTP clients and the crypto provider, and synchronizes the SDK clock with the server (waiting up to 10 seconds for the first synchronization). If it fails, the acquired resources are released and the exception is rethrown. Initializing an already initialized SDK throws an SdkException; release it first.

val sdkConfig = SdkConfig.Builder()
.setCloudAuthToken("AUTH_TOKEN")
.build()
val sdk = KDoordeckFactory.initialize(sdkConfig)

Release​

Call it at the end of your application's lifecycle. It stops the background tasks and closes the HTTP clients, giving the in-flight requests up to 5 seconds to finish. The stored context is kept, so releasing the SDK does not log the user out. Releasing an SDK that is not initialized does nothing.

KDoordeckFactory.release()