Zum Hauptinhalt springen
Android SDK Lite

Open the Human Token capture natively in your Android app using only the webAppToken of the process.

Markdown

The SDK Lite is the Unico Android SDK for the Human Token. It runs the capture in the Unico web experience embedded in the SDK and enters only with the webAppToken of a process created by your backend. The app holds no credentials: everything it needs comes from the token.

SDK version

Available from Android SDK 6.14.0 onwards, as the io.unico:capture-lite artifact.

How it works​

Prerequisites​

RequirementVersion / value
Minimum Android5.0 (API 21)
Kotlin1.8.22 or later
Java compatibilityJavaVersion.VERSION_1_8
Android Gradle Plugin (AGP)8.6.0 or later
Android StudioKoala Feature Drop (2024.1.2) or later
Required permissionsINTERNET, CAMERA
  • A backend that creates the process with Create Process and hands the webAppToken from the response to the app.
  • Token entry enabled for your account by Unico in the target environment.

Step 1: Add the dependency​

The SDK Lite is distributed through the Unico Maven repository. Add the repository to the dependencyResolutionManagement block of your settings file, then add io.unico:capture-lite to the module-level build file:

settings.gradle.kts
dependencyResolutionManagement {
repositories {
google()
mavenCentral()
maven("https://maven-sdk.unico.run/sdk-mobile")
}
}
app/build.gradle.kts (module)
dependencies {
implementation("io.unico:capture-lite:<version>")
}

Step 2: Get the webAppToken from your backend​

Your backend creates the process with Create Process and sends the app the webAppToken field of the response. The app passes it to the SDK as is. The token and link fields of the same response are for other uses: passed to the SDK, the token is rejected with error 73304.

  • One process per journey. Create a new process, and a new token, every time the user starts the capture.
  • Short-lived. The webAppToken is valid for 5 minutes. Create it right before opening the capture.
  • Same environment. The process and the SDK must use the same environment (UAT or PROD).
Warnung

Never embed credentials, access keys or a fixed token in the app. The webAppToken is created by your backend for each journey.

Step 3: Open the capture​

Get the webAppToken from your backend, build the SDK with AcessoBio, set the environment and call prepareAndOpenCamera(webAppToken, listener) with it. The call prepares the SDK and opens the capture at once.

import androidx.appcompat.app.AppCompatActivity
import androidx.lifecycle.lifecycleScope
import com.acesso.acessobio_android.AcessoBioListener
import com.acesso.acessobio_android.iAcessoBioSelfie
import com.acesso.acessobio_android.onboarding.AcessoBio
import com.acesso.acessobio_android.onboarding.models.Environment
import com.acesso.acessobio_android.services.dto.ErrorBio
import com.acesso.acessobio_android.services.dto.ResultCamera
import com.acesso.acessobio_android.services.dto.SuccessResult
import kotlinx.coroutines.launch

class CaptureActivity : AppCompatActivity() {

// Same environment used by your backend to create the process
private val environment = Environment.PROD

private val callback = object : AcessoBioListener {
override fun onErrorAcessoBio(errorBio: ErrorBio?) { }
override fun onUserClosedCameraManually() { }
override fun onSystemClosedCameraTimeoutSession() { }
override fun onSystemChangedTypeCameraTimeoutFaceInference() { }
}

private val selfieListener = object : iAcessoBioSelfie {
// Journey result. Required.
override fun onSuccess(successResult: SuccessResult) {
// Journey completed: send successResult.processId to your backend
}

// Required by the interface. The journey result arrives in onSuccess.
override fun onSuccessSelfie(result: ResultCamera) { }

override fun onErrorSelfie(errorBio: ErrorBio) {
// 73305 (expired token): create a new process and try again
}
}

fun startCapture() {
lifecycleScope.launch {
// Your backend calls Create Process and returns the `webAppToken` field of the response
val webAppToken = yourBackend.createHumanTokenProcess()

val camera = AcessoBio(this@CaptureActivity, callback)
.setEnvironment(environment)
.build()
camera.prepareAndOpenCamera(webAppToken, selfieListener)
}
}
}
onSuccess is required

iAcessoBioSelfie declares onSuccess with a default implementation, so the compiler does not require it. Without an override, the capture does not open and onErrorSelfie receives error 74001.

  • Prepare errors (rejected or expired token) and capture errors arrive in onErrorSelfie.
  • The capture does not run on emulators (error 73006).
  • onSuccess signals that the journey ended, not that the user was approved. Always read the result with Get Process or a webhook.

Environment​

The capture uses the environment set by setEnvironment on the builder. Use the environment where the process was created.

Error codes​

CodeWhenWhat to do
73006Running on an emulatorTest on a physical device
73304The webAppToken is blank or was rejected (invalid signature or content), including when the token field is passed insteadPass the webAppToken of a valid process
73305The token expiredCreate a new process and call prepareAndOpenCamera again with the new webAppToken
73701The call is not available in the SDK LiteUse prepareAndOpenCamera(webAppToken, listener)
74001The listener does not override onSuccessOverride onSuccess(successResult: SuccessResult)

What's next​

  • Fetch the result with Get Process and store data.humanToken.value with the user record.
  • Can't use the SDK Lite? Open the journey link instead, as described in Android.
  • Check the versions that include the lite edition in the SDK Lite Release Notes.
  • Integrating on iOS? See iOS SDK Lite.