Document capture (deprecated)
For security reasons, iOS SDK 3.5.0 and later no longer include the native document capture. The public API still exists for now, but calling it returns error 73905, "Unable to open document camera". It will be removed in an upcoming version. For more information, contact your CSM.
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.
The SDK does not perform any type of validation on what is being captured.
| Frame | Description |
|---|---|
DocumentEnums.CPF | Capture the CPF |
DocumentEnums.CNH | Capture the open CNH |
DocumentEnums.cnhFrente | Capture the front of the CNH |
DocumentEnums.cnhVerso | Capture the back of the CNH |
DocumentEnums.RG | Capture the open RG |
DocumentEnums.rgFrente | Capture the front of the RG |
DocumentEnums.rgVerso | Capture the back of the RG |
DocumentEnums.none | Generic rectangular frame for any other document |
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.
Step 1 — Implement AcessoBioManagerDelegate
AcessoBioManagerDelegate handles the SDK lifecycle callbacks. Implement the four mandatory methods:
| Method | When 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 |
- Swift
- Objective-C
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() { }
}
@implementation ViewController: UIViewController
- (void)viewDidLoad {
[super viewDidLoad];
unicoCheck = [[AcessoBioManager alloc]initWithViewController:self];
}
- (void)onErrorAcessoBioManager:(ErrorBio *)error { }
- (void)onSystemChangedTypeCameraTimeoutFaceInference { }
- (void)onSystemClosedCameraTimeoutSession { }
- (void)onUserClosedCameraManually { }
@end
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:
| Method | Description |
|---|---|
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 |
- Swift
- Objective-C
class ViewController: UIViewController, AcessoBioManagerDelegate,
DocumentCameraDelegate, AcessoBioDocumentDelegate {
func onSuccessDocument(_ result: DocumentResult!) { }
func onErrorDocument(_ errorBio: ErrorBio!) { }
}
// .h
@interface ViewController: UIViewController <AcessoBioManagerDelegate,
DocumentCameraDelegate, AcessoBioDocumentDelegate> {
AcessoBioManager *unicoCheck;
}
// .m
- (void)onSuccessDocument:(DocumentResult *)result {
NSLog(@"%@", result.base64);
}
- (void)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; callopenDocument(.CNH, delegate: self).onCameraFailedDocument(message)— camera preparation failed (ErrorPrepareis an extension ofErrorBio).
- Swift
- Objective-C
@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!) { }
- (IBAction)openCamera:(UIButton *)sender {
[[unicoCheck build] prepareDocumentCamera:self config:[YourUnicoConfigClass new]];
}
- (void)onCameraReadyDocument:(id)cameraOpener {
[cameraOpener openDocument:DocumentCNH delegate:self];
}
- (void)onCameraFailedDocument:(ErrorPrepare *)message { }
For the full result handling, see Receiving the result.