Unico IDCloud - DevCenter
HomepageAuthenticationAPIsSDKs
English (United States)
English (United States)
  • Welcome
  • GETTING STARTED
    • Unico IDCloud
    • Capabilities
    • Integration Methods
    • Capabilities and Integration Methods
  • INTEGRATIONS
    • Quickstart
    • Authentication
      • Creating a Service Account
      • Preparing to Make an Authenticated API Request
      • Additional Resources
        • Example in Javascript
        • Authentication Errors
        • Postman Collection
    • Integration by Unico
      • Overview
      • API
        • API Reference
          • CreateProcess
            • CreateProcess separated by flows
          • GetProcess
          • GetSelfie
          • GetEvidenceSet
            • Specification of the evidential set
          • GetDocumentSigned
          • GetEvidenceSign
        • Errors
      • Controlling the experience
        • Redirecting the user
        • SDK
        • QR Code
        • Customizations
      • Additional Resources
        • Postman Collection
        • PoCs available
    • Integration by Client
      • Overview
      • API
        • API Reference
          • Liveness + Identity Verification + Behavior Alert
          • Liveness + Identity Verification + Behavior Alert + Risk Score
          • Liveness + Validation (1:1) + Behavior Alert
          • Document Capture and Reuse
        • Response Scenarios
        • Additional Resources
          • Postman Collection
      • Capture standard (without SDK)
    • Webhook
    • SDK
      • Overview
      • Update Policy
      • SDK Integration
        • Android SDK
          • Installation Guide
          • Usage and Integration Guide
            • Selfie Capture
            • Document Capture
          • Error Handling Guide
          • Android Customization
          • Troubleshooting
          • Release notes
        • iOS SDK
          • Installation Guide
          • Usage and Integration Guide
            • Selfie Capture
            • Document Capture
          • Error Handling Guide
          • iOS Customization
          • Troubleshooting
          • Release notes
        • Flutter SDK
          • Installation Guide
          • Usage and Integration Guide
            • Selfie Capture
            • Document Capture
          • Error Handling Guide
          • Flutter Customization
          • Troubleshooting
          • Release notes
        • Web SDK
          • Installation Guide
          • Usage and Integration Guide
            • Selfie Capture
            • Document Capture
            • Accessibility
          • Error Handling Guide
          • Web Customization
          • Release notes
      • Additional Resources
        • Available PoCs
        • Best Practices for SDK Implementation
  • help & faq
    • Glossary
    • Help Center
Powered by GitBook

Institucional

  • Sobre nós

Copyright © 2024 unico. All rights reserved

On this page
  • Available Document Frames
  • Initializing the SDK
  • Implementing Callback Functions
  • Implementing Delegates for Camera Events
  • onSucessDocument Method
  • Método onErrorDocument
  • Preparing and Opening the Camera
  • Making a POST Request to the Client API

Was this helpful?

Export as PDF
  1. INTEGRATIONS
  2. SDK
  3. SDK Integration
  4. iOS SDK
  5. Usage and Integration Guide

Document Capture

In this section, you will find all the necessary information for using and integrating the Unico IDCloud SDK into your iOS applications for document capture

PreviousSelfie CaptureNextError Handling Guide

Last updated 2 months ago

Was this helpful?


This guide has been designed to help you quickly and easily implement the Android SDK. Below, you'll find the step-by-step process for the complete integration. If you wish to customize the experience further, check out the iOS Customization section.

Available Document Frames


In this camera mode, there is a capture frame to assist the user in positioning the document correctly. After positioning the document correctly, the user should click the button to capture the photo of the document.

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

In this camera mode, it is possible to capture the following documents:

  • RG: Capture of the RG (separate front and back).

  • CNH: Capture of the CNH opened.

  • CNH Front: Capture of the front of the CNH.

  • CNH Back: Capture of the back of the CNH.

  • CPF: Capture of the CPF document.

  • Without Silhouette: Capture of a generic document.

Initializing the SDK


To get started with the Unico IDCloud iOS SDK, import the SDK and implement the AcessoBioManagerDelegate interface within the ViewController you wish to use.

The implementation of this class is straightforward and can be done with just a few lines of code. All you need to do is instantiate the builder by providing the relevant context and override the callback methods with the business logic of your application:

.m:
#import "ViewController.h"
#import <AcessoBio/AcessoBio.h>

@interface ViewController ()
@end

@implementation ViewController
- (void)viewDidLoad {
    [super viewDidLoad];   
    unicoCheck = [[AcessoBioManager alloc]initWithViewController:self];
}
   
- (void)onErrorAcessoBioManager:(ErrorBio *)error {
  // Your code
}

- (void)onSystemChangedTypeCameraTimeoutFaceInference {
  // Your code
}

- (void)onSystemClosedCameraTimeoutSession {
  // Your code
}

- (void)onUserClosedCameraManually {
  // Your code
}

@end
import UIKit
import AcessoBio

class ViewController: UIViewController, AcessoBioManagerDelegate {
  var unicoCheck: AcessoBioManager!

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

  func onErrorAcessoBioManager(_ error: ErrorBio!) {
    // Your code
  }

  func onUserClosedCameraManually() {
    // Your code
  }

  func onSystemClosedCameraTimeoutSession() {
    // Your code
  }

  func onSystemChangedTypeCameraTimeoutFaceInference() {
    // Your code
  }
}   

Implementing Callback Functions


Note that, as shown in the previous example, the implementation work of the AcessoBioManagerDelegate interface is largely about configuring the callback methods. Each method is called in a specific situation based on the SDK's response.

Simply override the methods illustrated in the previous step with your application's business logic:

1

onErrorAcessoBioManager(_ error: ErrorBio!)

This method is invoked whenever an implementation error occurs while using any of the methods, such as providing an incorrect document type for the document capture functionality.

2

onUserClosedCameraManually()

This method is invoked whenever the user manually closes the camera, such as by clicking the "Back" button.

3

onSystemClosedCameraTimeoutSession()

This method is also invoked once the maximum session time is reached (without capturing any image).

It can be configured in the builder through the setTimeoutSession method. This method should receive the maximum session time in seconds. You can modify the maximum session time for your user when using the face detection feature (Selfie camera with intelligent capture). If the time limit for capturing the photo is exceeded, you can present a customizable message or instruction to the user. The default value is 40 seconds, and the minimum value is also 40 seconds.

4

onSystemChangedTypeCameraTimeoutFaceInference()

This method is invoked once the maximum time for detecting the user's face is reached (without detecting anything). In this case, the camera mode is automatically switched to manual capture mode (without the intelligent capture silhouette).

The maximum capture time when using face detection (Selfie camera with intelligent capture) is 13 seconds. If the user faces difficulties capturing the photo using face detection and exceeds the time limit set in the process, the capture automatically switches to manual mode, aiming to facilitate the process for the user (TimeoutToFaceInference).

All of the above methods must be implemented as indicated in your project (even if with no logic). Otherwise, the project will not compile successfully.

Implementing Delegates for Camera Events


The camera opening method (which is called in the next step) needs to know what to do when it successfully captures an image or encounters an error during the process. The "actions" to be taken are specified to the camera opening method through the configuration of delegates, which are called in success or error situations.

By configuring the delegates, you can define what happens in your app during error situations (onErrorDocument method) or success situations (onSuccessDocument method) when capturing images.

To configure the delegates, you need to implement the DocumentCameraDelegate and AcessoBioDocumentDelegate interfaces:

.h:
#import <UIKit/UIKit.h>
#import <AcessoBio/AcessoBio.h>
#import "SelfieCameraDelegate.h"

@interface ViewController: UIViewController <AcessoBioManagerDelegate, DocumentCameraDelegate, 
  AcessoBioDocumentDelegate> {
  AcessoBioManager *unicoCheck;
  // Your code from previous and next steps here
}
import UIKit
import AcessoBio

class ViewController: UIViewController, AcessoBioManagerDelegate, DocumentCameraDelegate, 
  AcessoBioDocumentDelegate {    
  // Your code from previous and next steps here
}

onSucessDocument Method


When an image is successfully captured, this method is invoked and returns an object of type ResultCamera, which is used later in the REST API request.

- (void)onSuccessDocument:(DocumentResult *)result {
    NSLog(@"%@", result.base64);
} 
func onSuccessDocument(_ result: DocumentResult!) {
    // Your code
 }

The ResultCamera object returns two attributes: base64 and encrypted.

  • The base64 attribute can be used if you want to display a preview of the image in your app.

  • Both the encrypted and base64 attributes can be sent in the REST API calls of the by Client.

Método onErrorDocument


When an error occurs during image capture, this method is invoked and returns an object of type ErrorBio.

- (void)onErrorDocument:(ErrorBio *)errorBio {
    // Your code
}
func onErrorDocument(_ errorBio: ErrorBio!) {
    // Your code
 }

Learn more about the ErrorBio types in the error handling section of the SDK.

Preparing and Opening the Camera


To open the camera, it is necessary to prepare it using the method prepareDocumentCamera. This method takes as a parameter the implementation of the DocumentCameraDelegate class and the JSON with the credentials generated in the previous step.

.h:
#import <UIKit/UIKit.h>
#import <AcessoBio/AcessoBio.h>
#import "SelfieCameraDelegate.h"

@interface ViewController: UIViewController < AcessoBioManagerDelegate,
DocumentCameraDelegate, AcessoBioDocumentDelegate> {
    AcessoBioManager *unicoCheck;
}

.m:
- (IBAction)openCamera:(UIButton *)sender {
    [[unicoCheck build] prepareDocumentCamera:self config:[YourUnicoConfigClass new]];
}
import UIKit
import AcessoBio

class ViewController: UIViewController, AcessoBioManagerDelegate, 
DocumentCameraDelegate, AcessoBioDocumentDelegate {
    @IBAction func openCamera(_ sender: Any) {
        unicoCheck.build().prepareDocumentCamera(self, config: YourUnicoConfigClass())
    }
}

When the camera is ready, the event onCameraReadyDocument is triggered, which receives as a parameter an object of type AcessoBioCameraOpenerDelegate.

You should override this method, opening the camera with the object received through the openDocument() method, receiving the document type parameters to be captured, which are:

Parameter
Description

DocumentEnums.CPF

Capture the front of 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 RGo RG

DocumentEnums.none

Capture any other document

If you need to capture a document for which we don't have a specific frame (e.g., RNE, among others), use the DocumentEnums.none frame, which will provide a generic, rectangular frame that can be used to guide any capture.

The delegates implemented above (referred to here as Self):

- (void)onCameraReadyDocument:(id)cameraOpener {
    [cameraOpener openDocument:DocumentCNH delegate:self];
}

- (void)onCameraFailedDocument:(ErrorPrepare *)message {
  // Your code
}
func onCameraReadyDocument(_ cameraOpener: AcessoBioCameraOpenerDelegate!) {
    cameraOpener.openDocument(DocumentEnums.CNH, delegate: self)
}
 
func onCameraFailedDocument(_ message: ErrorPrepare!) {
  // Your code
}

The ErrorPrepare type is an extension of ErrorBio, thus containing all its properties. Learn more about the ErrorBio type in the SDK error handling section.

If an error occurs while preparing the camera, the onCameraFailedDocument event is triggered. You should implement this method according to the business logic of your app.

In case of success, the onSuccessDocument event is triggered, as explained in the section above.

Making a POST Request to the Client API



When invoked, the method receives a parameter of type ErrorBio, which contains details about the error. Learn more about the ErrorBio type in the article of this SDK.

If you need to convert the base64 to bitmap, the standard method does not work for Android. You need to split the string at the comma (,) to make it work. If you want to learn more, read the article:

Capturing the images is only the first part of the journey. After capturing the image, you need to send the base64 generated by the SDK to the by Client REST APIs. Learn more in the section of the by Client.

Still need help?

Didn't find something or still need help? If you're already a client or partner, you can reach out through our .

error handling
How to convert a Base64 string into a Bitmap image to show it in an ImageView?
CreateProcess
​
Help Center