Skip to main content

Document capture

Capture of identity documents. Supports RG (front only or front and back), CNH (front and back), and CPF, when combined with the Document Capture and Reuse capability.

For the full list of supported document types and their enum values, see API Reference > Enums.

Starting a document capture
Step 1 — Implement AcessoBioListener

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

MethodWhen 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
val callback = object : AcessoBioListener {
override fun onErrorAcessoBio(errorBio: ErrorBio?) { }
override fun onUserClosedCameraManually() { }
override fun onSystemClosedCameraTimeoutSession() { }
override fun onSystemChangedTypeCameraTimeoutFaceInference() { }
}
Step 2 — Implement iAcessoBioDocument

iAcessoBioDocument handles the document capture result callbacks:

MethodDescription
onSuccessDocument(result)Capture succeeded — returns ResultCamera with base64 (preview) and encrypted (JWT for the API)
onErrorDocument(errorBio)Capture failed — returns an ErrorBio with code and description
val documentListener = object : iAcessoBioDocument {
override fun onSuccessDocument(result: ResultCamera?) { }
override fun onErrorDocument(errorBio: ErrorBio?) { }
}
Step 3 — Call prepareDocumentCamera

With acessoBioBuilder initialized and both listeners implemented, call prepareDocumentCamera passing the SDK config (the UnicoConfig created in Initialization), the desired DocumentType, and a DocumentCameraListener:

  • onCameraReady — camera is ready; call open passing the documentListener from Step 2.
  • onCameraFailed — camera preparation failed; handle the error message.
acessoBioBuilder
.build()
.prepareDocumentCamera(UnicoConfig(), DocumentType.CNH, object : DocumentCameraListener {
override fun onCameraReady(cameraOpener: UnicoCheckCameraOpener.Document?) {
cameraOpener?.open(documentListener)
}
override fun onCameraFailed(message: String?) { }
})

For the full result handling, see Receiving the result.