LUNA ID initialization#
Applies to LUNA ID for Android only.
Before using any LUNA ID features, you must initialize the engine with a valid configuration.
Main initialization method#
Call the initEngine() method to start the LUNA ID initialization process with your desired configuration.
fun initEngine(
context: Context,
lunaConfig: LunaConfig,
apiHumanConfig: ApiHumanConfig? = null,
license: File? = null,
timeoutMillis: Long = 30_000L
)
| Component | Description |
|---|---|
context: Context |
Specifies your application context. |
lunaConfig: LunaConfig |
Specifies core LUNA ID configuration. |
apiHumanConfig: ApiHumanConfig? |
Optional. Specifies configuration for Luna Web API. |
license: File? |
Specifies the license file. |
timeoutMillis: Long |
Specifies an initialization timeout, in milliseconds. The default value is 30 seconds. |
Example:
val lunaConfig = LunaConfig.create(
livenessType = LivenessType.Offline,
bestShotsCount = 1
)
LunaID.initEngine(
context = applicationContext,
lunaConfig = lunaConfig
)
For more information, see Initial setup of LUNA ID for Android.
Initialization status#
Track LUNA ID readiness with engineInitStatus flow:
val engineInitStatus: StateFlow<EngineInitStatus>
Status values:
| Status | Description |
|---|---|
NotInitialized |
LUNA ID is not initialized yet. |
InProgress |
Initialization is in progress. |
Success |
Initialization completed successfully. |
Failure(cause: Throwable?) |
Initialization failed. |
Example:
lifecycleScope.launch {
LunaID.engineInitStatus.collect { status ->
when (status) {
is LunaID.EngineInitStatus.Success -> {
// LUNA ID is ready for use
}
is LunaID.EngineInitStatus.Failure -> {
// Error handling
}
else -> { /* processing other statuses */ }
}
}
}
For more information, see Getting LUNA ID status after intitialization.
Device fingerprint#
The getFingerprint() method returns a unique device identifier that can be used for license activation.
fun getFingerprint(app: Application): String?
For more information, see Device fingerprinting.
License cache management#
Call the resetLicenseCache() method to clear all locally stored license data from the device:
suspend fun resetLicenseCache(context: Context): Boolean
| Return value | Description |
|---|---|
true |
One or more license cache fines were successfully deleted. |
false |
No cache file were found or could be deleted. |
For more information, see Resetting the license cache.