Skip to main content

Document capture

Capture of identity documents. The SDK presents a frame to assist the user in positioning the document; after positioning, the user clicks the button to capture the photo.

No content validation

The SDK does not perform any type of validation on what is being captured.

Available document frames
FrameDescription
DocumentEnums.CPFCapture the CPF
DocumentEnums.CNHCapture the open CNH
DocumentEnums.cnhFrenteCapture the front of the CNH
DocumentEnums.cnhVersoCapture the back of the CNH
DocumentEnums.RGCapture the open RG
DocumentEnums.rgFrenteCapture the front of the RG
DocumentEnums.rgVersoCapture the back of the RG
DocumentEnums.noneGeneric rectangular frame for any other document
Generic frame

If you need to capture a document for which there is no specific frame (e.g., RNE), use DocumentEnums.none — a generic, rectangular frame that can be used to guide any capture.

For the full list of supported document types, see API Reference > Enums.

Starting a document 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 DocumentCameraDelegate and AcessoBioDocumentDelegate

These delegates handle the document capture result callbacks:

MethodDescription
onSuccessDocument(result)Capture succeeded — returns DocumentResult with base64 (preview) and encrypted (JWT for the API)
onErrorDocument(errorBio)Capture failed — returns an ErrorBio with code and description
class ViewController: UIViewController, AcessoBioManagerDelegate,
DocumentCameraDelegate, AcessoBioDocumentDelegate {

func onSuccessDocument(_ result: DocumentResult!) { }
func onErrorDocument(_ errorBio: ErrorBio!) { }
}
Step 3 — Call prepareDocumentCamera and openDocument

Call prepareDocumentCamera passing the SDK config. When the camera is ready, onCameraReadyDocument is triggered with an AcessoBioCameraOpenerDelegate — open the camera using openDocument() and pass the desired DocumentEnums:

  • onCameraReadyDocument(cameraOpener) — camera is ready; call openDocument(.CNH, delegate: self).
  • onCameraFailedDocument(message) — camera preparation failed (ErrorPrepare is an extension of ErrorBio).
@IBAction func openCamera(_ sender: Any) {
unicoCheck.build().prepareDocumentCamera(self, config: YourUnicoConfigClass())
}

func onCameraReadyDocument(_ cameraOpener: AcessoBioCameraOpenerDelegate!) {
cameraOpener.openDocument(DocumentEnums.CNH, delegate: self)
}

func onCameraFailedDocument(_ message: ErrorPrepare!) { }

For the full result handling, see Receiving the result.