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:
| 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 iAcessoBioDocument
iAcessoBioDocument handles the document capture result callbacks:
| Method | Description |
|---|---|
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 |
- Kotlin
- Java
val documentListener = object : iAcessoBioDocument {
override fun onSuccessDocument(result: ResultCamera?) { }
override fun onErrorDocument(errorBio: ErrorBio?) { }
}
iAcessoBioDocument documentListener = new iAcessoBioDocument() {
@Override
public void onSuccessDocument(ResultCamera result) { }
@Override
public void 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; callopenpassing thedocumentListenerfrom Step 2.onCameraFailed— camera preparation failed; handle the error message.
- Kotlin
- Java
acessoBioBuilder
.build()
.prepareDocumentCamera(UnicoConfig(), DocumentType.CNH, object : DocumentCameraListener {
override fun onCameraReady(cameraOpener: UnicoCheckCameraOpener.Document?) {
cameraOpener?.open(documentListener)
}
override fun onCameraFailed(message: String?) { }
})
acessoBioBuilder
.build()
.prepareDocumentCamera(new UnicoConfig(), DocumentType.CNH, new DocumentCameraListener() {
@Override
public void onCameraReady(UnicoCheckCameraOpener.Document cameraOpener) {
cameraOpener.open(documentListener);
}
@Override
public void onCameraFailed(String message) { }
});
For the full result handling, see Receiving the result.