Liveness (biometric selfie)
Biometric selfie capture with embedded liveness verification. The SDK guides the user until a biometrically valid frame is obtained via SmartFrames and returns the image as Base64 + JWT (JSON Web Token — a signed payload sent to your backend to call the REST API).
This capture type uses the Liveness capability. For a conceptual overview of how Liveness works, refer to the Liveness capability page.
The SDK manages the full capture session:
- Opens the camera with the SmartFrame overlay.
- Guides the user to position their face within the frame.
- Validates liveness — the session only completes when the user is physically present.
- Returns a
ResultCameraobject withbase64andencrypted(JWT).
Step 1 — Implement AcessoBioListener
AcessoBioListener handles the SDK lifecycle callbacks. Implement the four mandatory methods:
| Method | When it's called |
|---|---|
onErrorAcessoBio(errorBio) | An error occurred during SDK operation |
onUserClosedCameraManually() | The user manually closed the camera |
onSystemClosedCameraTimeoutSession() | The session time limit was reached — see Session limits |
onSystemChangedTypeCameraTimeoutFaceInference() | The face inference time limit was reached — switches to manual capture — see Session limits |
- Kotlin
- Java
val callback = object : AcessoBioListener {
override fun onErrorAcessoBio(errorBio: ErrorBio?) { }
override fun onUserClosedCameraManually() { }
override fun onSystemClosedCameraTimeoutSession() { }
override fun onSystemChangedTypeCameraTimeoutFaceInference() { }
}
AcessoBioListener callback = new AcessoBioListener() {
@Override
public void onErrorAcessoBio(ErrorBio errorBio) { }
@Override
public void onUserClosedCameraManually() { }
@Override
public void onSystemClosedCameraTimeoutSession() { }
@Override
public void onSystemChangedTypeCameraTimeoutFaceInference() { }
};
Step 2 — Implement iAcessoBioSelfie
iAcessoBioSelfie handles the selfie capture result callbacks:
| Method | Description |
|---|---|
onSuccessSelfie(result) | Capture succeeded — returns ResultCamera with base64 (preview) and encrypted (JWT for the API) |
onErrorSelfie(errorBio) | Capture failed — returns an ErrorBio with code and description |
The interval between generating encrypted and submitting it to the API must not exceed 10 minutes.
- Kotlin
- Java
val selfieListener = object : iAcessoBioSelfie {
override fun onSuccessSelfie(result: ResultCamera?) { }
override fun onErrorSelfie(errorBio: ErrorBio?) { }
}
iAcessoBioSelfie selfieListener = new iAcessoBioSelfie() {
@Override
public void onSuccessSelfie(ResultCamera result) { }
@Override
public void onErrorSelfie(ErrorBio errorBio) { }
};
Step 3 — Call prepareCamera
With unicoCheckCamera initialized and both listeners implemented, call prepareCamera passing the SDK config (the UnicoConfig created in Initialization) and a SelfieCameraListener:
onCameraReady— camera is ready; callopenpassing theselfieListenerfrom Step 2.onCameraFailed— camera preparation failed; handle the error message.
- Kotlin
- Java
unicoCheckCamera
.prepareCamera(UnicoConfig(), object : SelfieCameraListener {
override fun onCameraReady(cameraOpener: UnicoCheckCameraOpener.Selfie?) {
cameraOpener?.open(selfieListener)
}
override fun onCameraFailed(message: String?) { }
})
unicoCheckCamera
.prepareCamera(new UnicoConfig(), new SelfieCameraListener() {
@Override
public void onCameraReady(UnicoCheckCameraOpener.Selfie cameraOpener) {
cameraOpener.open(selfieListener);
}
@Override
public void onCameraFailed(String message) { }
});
For the full result handling, see Receiving the result.