Skip to main content

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.

Capability

This capture type uses the Liveness capability. For a conceptual overview of how Liveness works, refer to the Liveness capability page.

How it works

The SDK manages the full capture session:

  1. Opens the camera with the SmartFrame overlay.
  2. Guides the user to position their face within the frame.
  3. Validates liveness — the session only completes when the user is physically present.
  4. Returns a SelfieResult (alias ResultCamera) object with base64 and encrypted (JWT).
Camera mode (smart capture)

The SDK has intelligent framing and automatic capture enabled by default. Configure the camera mode in your builder as follows:

unicoCheck.setSmartFrame(true)
unicoCheck.setAutoCapture(true)
Starting a liveness capture
Step 1 — Implement AcessoBioManagerDelegate

AcessoBioManagerDelegate handles the SDK lifecycle callbacks. Implement the four mandatory methods:

MethodWhen it's called
onErrorAcessoBioManager(error)An error occurred during SDK operation
onUserClosedCameraManually()The user manually closed the camera
onSystemClosedCameraTimeoutSession()The 40-second session limit was reached
onSystemChangedTypeCameraTimeoutFaceInference()No face detected for 13 seconds — switches to manual capture
class ViewController: UIViewController, AcessoBioManagerDelegate {
var unicoCheck: AcessoBioManager!

override func viewDidLoad() {
super.viewDidLoad()
unicoCheck = AcessoBioManager(viewController: self)
}

func onErrorAcessoBioManager(_ error: ErrorBio!) { }
func onUserClosedCameraManually() { }
func onSystemClosedCameraTimeoutSession() { }
func onSystemChangedTypeCameraTimeoutFaceInference() { }
}
Mandatory delegate methods

All four delegate methods above must be created in your project (even without any logic). Otherwise, the project will not compile successfully.

Step 2 — Implement SelfieCameraDelegate and AcessoBioSelfieDelegate

These delegates handle the selfie capture result callbacks:

MethodDescription
onSuccessSelfie(result)Capture succeeded — returns SelfieResult with base64 (preview) and encrypted (JWT for the API)
onErrorSelfie(errorBio)Capture failed — returns an ErrorBio with code and description
Token expiry

The interval between generating encrypted and submitting it to the API must not exceed 10 minutes.

class ViewController: UIViewController, AcessoBioManagerDelegate,
SelfieCameraDelegate, AcessoBioSelfieDelegate {

func onSuccessSelfie(_ result: SelfieResult!) { }
func onErrorSelfie(_ errorBio: ErrorBio!) { }
}
Step 3 — Call prepareSelfieCamera and open

Call prepareSelfieCamera passing the SDK config. When the camera is ready, the onCameraReady event is triggered with an AcessoBioCameraOpenerDelegate — open the camera through the open() method:

  • onCameraReady(cameraOpener) — camera is ready; call open(self).
  • onCameraFailed(message) — camera preparation failed (ErrorPrepare is an extension of ErrorBio).
@IBAction func openCamera(_ sender: Any) {
unicoCheck.build().prepareSelfieCamera(self, config: YourUnicoConfigClass())
}

func onCameraReady(_ cameraOpener: AcessoBioCameraOpenerDelegate!) {
cameraOpener.open(self)
}

func onCameraFailed(_ message: ErrorPrepare!) { }
Monitoring data collection

The prepareSelfieCamera method provides an overload that accepts metadata via PrepareInfo to assist in identifying the user session and the flow:

  • externalUserId (String, required) — User identifier within your system. Automatically hashed using SHA-256 before transmission.
  • useCase (String, optional) — Identifier for the context or flow currently running (e.g., "account_opening", "password_recovery"). Transmitted in plain text.
let prepareInfo = PrepareInfo(
externalUserId: "external_user_id",
useCase: "use_case"
)
unicoCheck.build().prepareSelfieCamera(
self,
config: YourUnicoConfigClass(),
prepareInfo: prepareInfo
)

For the full result handling, see Receiving the result.