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
  • Initializing the SDK
  • Environment configuration
  • Implementing the Callback Functions
  • Configuring Camera Mode
  • Implementing Delegates for Camera Events
  • onSuccessSelfie Method
  • onErrorSelfie Method
  • Environment Configuration
  • Prepare and Open 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

Selfie Capture

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

PreviousUsage and Integration GuideNextDocument Capture

Last updated 2 months ago

Was this helpful?


This guide has been created to help you implement the Unico iOS SDK quickly and easily. Below is the step-by-step process for the entire integration. Afterward, if you wish to personalize the experience, be sure to check the section.

Initializing the SDK


To get started with the Unico Check iOS SDK, import the SDK and implement the AcessoBioManagerDelegate interface within the ViewController you want 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, providing the context and environment in question, and override the callback methods with the business logic of your application:

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

@implementation ViewController: UIViewController
- (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 
  }
}

Environment configuration


Configure the environment that will be used to run the SDK. Use the enumerated environment that contains the following enumerates:

  • PROD: for production environment;

  • UAT: for approval environment.

See how to implement it in the example below:

  [unicoCheck setEnvironment:UAT];
 unicoCheck.setEnvironment(.UAT);

Implementing the Callback Functions


Note that, as shown in the previous example, the implementation of the AcessoBioManagerDelegate interface mainly involves configuring the callback methods. Each method is called in a specific situation in the SDK's return process.

You simply need to override the methods demonstrated in the previous step with the business logic of your application:

1

onErrorAcessoBioManager(_ error: ErrorBio!)

This method is invoked when any implementation error occurs while using one 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 invoked as soon as 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 change the maximum session time for your user by using the face detection feature (Selfie camera with smart capture). If the time exceeds the duration specified for the process to capture the photo, you can display 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 as soon as the maximum time for detecting a 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 smart capture) is 13 seconds. If the user encounters any difficulty capturing the photo through face detection and exceeds the time specified in the process, the capture automatically switches to manual mode to facilitate the user's action (TimeoutToFaceInference).

All the methods above must be created as indicated in your project (even without any logic). Otherwise, the project will not compile successfully.

Configuring Camera Mode


The SDK has intelligent framing and automatic capture configured and enabled by default. As a result, you should configure the camera mode in your builder as follows:

.m:
- (IBAction)configureSmartCamera:(UIButton *)sender {
   [unicoCheck setSmartFrame:true];
   [unicoCheck setAutoCapture:true];
}
@IBAction func configureSmartCamera(_ sender: Any) {
    unicoCheck.setSmartFrame(true)
    unicoCheck.setAutoCapture(true)    
}

The false/true values for the methods above do not change the capture experience; they are only used for the internal logic of the SDK's functionality.

Implementing Delegates for Camera Events


The camera opening method needs to know what to do when it successfully captures an image or encounters an error during the process. "What to do" is informed to the camera opening method through the configuration of delegates that are called in success or error situations.

By configuring the delegates, you can specify what happens in your app in error situations (method onErrorSelfie) or success (method onSuccessSelfie) when capturing images.

To configure the delegates, you need to implement the SelfieCameraDelegate and AcessoBioSelfieDelegate interfaces:

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

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

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

onSuccessSelfie Method


When successfully capturing an image, this method is invoked and returns an object of type SelfieResult, which is later used in the REST API calls.

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

The ResultCamera object returns 2 attributes: base64 and encrypted:

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

  • The encrypted attribute is strictly intended for sending the image through the by Client APIs. It should not be opened or serialized, as its characteristics may change without prior notice. Its use should be exclusive in interactions with the APIs to ensure data integrity and security. Unico is not responsible for any damages resulting from this practice, as modifications can occur unexpectedly.

  • The base64/encrypted files may vary in size depending on various factors, including the quality of the devices and photos generated by them, as well as Unico’s business rules. To avoid issues in your application, do not limit the size of the string generated by the SDK for the files within your programming logic or infrastructure.

onErrorSelfie Method


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

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

Environment Configuration


If not configured, the SDK uses the environment set through the configuration file (getHostKey). If getHostKey is not being used, an error will be returned.

It is possible to configure the environment to be used during the execution of the SDK. Use the EnvironmentEnum enumerated type, which contains the following values:

  • EnvironmentEnum.PROD: for the Production environment

  • EnvironmentEnum.UAT: for the Staging environment

See how to implement it in the example below:

[unicoCheck setEnvironment:PROD];
unicoCheck.setEnvironment(.PROD);

Prepare and Open Camera


To proceed with opening the camera, you must first prepare it using the prepareSelfieCamera method. This method takes as parameters the implementation of the SelfieCameraDelegate class and the JSON containing the credentials generated in the previous step.

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

@interface ViewController: UIViewController <AcessoBioManagerDelegate,
SelfieCameraDelegate, AcessoBioSelfieDelegate> {
    AcessoBioManager *unicoCheck;
}

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

class ViewController: UIViewController, AcessoBioManagerDelegate,
  SelfieCameraDelegate, AcessoBioSelfieDelegate {
    @IBAction func openCamera(_ sender: Any) {
        unicoCheck.build().prepareSelfieCamera(self, config: YourUnicoConfigClass())
    }
}

Once the camera is prepared, the onCameraReady event is triggered and receives an object of type AcessoBioCameraOpenerDelegate as a parameter.

You should override this method and open the camera using the object received through the open() method:

- (void)onCameraReady:(id)cameraOpener {
    [cameraOpener open:self];
}

- (void)onCameraFailed:(ErrorPrepare *)message {
    // Your code
}
func onCameraReady(_ cameraOpener: AcessoBioCameraOpenerDelegate!) {
    cameraOpener.open(self)
 }
 
func onCameraFailed(_ message: ErrorPrepare!) {
    // Your code
 }

If any error occurs while preparing the camera, the onCameraFailed event is triggered. You should implement this method applying your app's business rules.

Making a POST Request to the Client API


For security reasons, the time interval between the generation of the encrypted and its submission via one of the available flows must be no more than 10 minutes. Submissions made beyond this period will be automatically rejected by the API.


When invoked, the method will receive a parameter of type ErrorBio that contains details of the error. For more information on the ErrorBio type, refer to the article in this SDK documentation.

The encrypted attribute must be sent in the REST API calls of

If you want to convert the base64 to bitmap, the standard method doesn’t work for iOS. You need to split the string starting from the comma (,) to make it work. To learn more, read this article:

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

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

Capturing the images is only the first part of the journey. After capturing the image, it is necessary to send the encrypted generated by the SDK to the by Client REST APIs. Learn more in the section of 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 .

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