Starting Liveness Flow
The Liveness flow has three steps:
configure(): give the SDK your credentials, once.prewarm(): fetch the liveness session while the user is still on the previous screen.startLiveness(): open the camera and receive the result.
Configure
Create a CafLivenessConfig and pass it to configure(). This only stores the context and configuration. It makes no network request, so it is safe to call early.
val livenessConfig = CafLivenessConfig(
mobileToken = "<YOUR_MOBILE_TOKEN>",
stage = CafStage.PROD,
personId = "<PERSON_ID>",
showLoading = true,
enableSecurity = true
)
CafFaceLivenessLite.instance.configure(context, livenessConfig)CafLivenessConfig Parameters
personId
—
Required. Identifies the user for the liveness process.
stage
PROD
Target environment: PROD, BETA, or DEV.
showLoading
true
Shows loading indicators during processing when true.
enableSecurity
true
When enabled, runs device security validation before and during liveness. See Security Checks.
Pre-warm
Call prewarm() as soon as you know Liveness is coming — when the user reaches the screen before it, or when the "Start" button becomes visible. The SDK creates the Liveness session in the background so startLiveness() does not have to wait for it.
prewarm() takes no parameters, returns immediately and reports nothing — the work continues in the background. It requires configure() to have been called first.
Start Liveness
Call startLiveness() with a callback to handle the results and events triggered during the Liveness flow.
Complete example
Events
Every run delivers its events to the listener passed to startLiveness(), on the main thread. A run always ends with exactly one of Success, Failure, Error or Cancelled.
Success(signedResponse: String)
The capture completed. Forward the signedResponse to your backend.
Failure(signedResponse: String, type: CafFailureType, description: String)
The capture ran but did not pass. Guide the user with the type and forward the signedResponse to your backend. See Mobile Failures.
Error(type: CafLivenessErrorType, description: String, cause: Throwable)
The run could not start or finish. No signedResponse. See Android Errors.
Cancelled
The user closed the capture screen. Go back to the previous screen without an error message.
Loading / Loaded
The SDK started / stopped waiting. Use them to show or hide your own loading indicator.
Changing the user or credentials
If you call configure() again with a different mobileToken or personId, any pre-warmed session is discarded, since it belongs to the previous user. Call prewarm() again after reconfiguring.
Releasing the SDK
release() cancels the Liveness in progress and discards any pre-warmed session. The configuration from configure() is kept, so you can call prewarm() or startLiveness() again without reconfiguring.
Debugging
To see the SDK logs in Logcat, enable logging. Logs only appear when your app is debuggable; in release builds the flag is ignored.
Next step
Forward the signedResponse to your backend, which validates it and retrieves the result: Backend Setup.
Last updated

