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 Listeners for Camera Events
  • onSucessSelfie Method
  • onErrorSelfie Method
  • 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. Flutter 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 Flutter 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 Flutter SDK quickly and easily. Below is the step-by-step process for the entire integration. After that, if you wish to customize the experience, be sure to check the section.

Initializing the SDK


To get started, create an instance of the builder (generated through the UnicoCheckBuilder interface), providing the context and environment as parameters, along with the implementation of the UnicoListener class.

The implementation of this class is quite simple and can be done with just a few lines of code. All you need to do is override the callback methods with your application's business logic.

class _MyHomePageState extends State<MyHomePage> implements UnicoListener {

    late UnicoCheckBuilder _unicoCheck;

    
      @override
      void onErrorUnico(UnicoError error) {}

      @override
      void onUserClosedCameraManually() {}

      @override
      void onSystemChangedTypeCameraTimeoutFaceInference() {}

      @override
      void onSystemClosedCameraTimeoutSession() {}
}

Environment configuration


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

  • UnicoEnvironment.PROD: for production environment;

  • UnicoEnvironment.UAT: for approval environment.

See how to implement it in the example below:

 _unicoCheck.setEnvironment(unicoEnvironment: UnicoEnvironment.UAT);

Implementing the Callback functions


Note that, as shown in the previous example, the implementation of the UnicoListener class mostly involves configuring the callback methods. Each method will be called in a specific situation based on the SDK's return.

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

1

onErrorUnico(UnicoError error)

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 user exceeds the time defined in your 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 changed to manual capture mode (without the smart capture silhouette).

The maximum capture time when using face detection (Selfie camera with smart capture) is 13 seconds. If the user has difficulty capturing the photo via face detection and exceeds the time set in your process, the capture mode automatically switches to manual to make the process easier for the user (TimeoutToFaceInference).

All of the above methods must be created as indicated in your project (even if with no 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:

UnicoCheckCameraOpener _opener = new UnicoCheck (this)
    .setAutoCapture(autoCapture: true)
    .setSmartFrame(smartFrame: true)
    .build();

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

Implementing Listeners for Camera Events


The implementation of these listener methods must be done through an instance of the UnicoSelfie class.

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 by implementing listeners, which are called in cases of success or error.

Through the implementation of these listeners, you can specify what happens in your app in case of error (onErrorSelfie method) or success (onSuccessSelfie method) when capturing images.

onSucessSelfie Method


When successfully capturing an image, this method is invoked and returns an object of type ResultCamera, which is later used in the REST API requests:

@override
void onSuccessSelfie(ResultCamera result) { }

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 must be sent in the REST API calls by Client.

  • 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 can be altered without prior notice. Its use should be exclusive for 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 several factors, including the quality of the devices and the 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 these files in your programming logic or infrastructure.

onErrorSelfie Method


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

@override
void onErrorSelfie(UnicoError error) { }

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

Preparing and Opening the Camera


The openCameraSelfie method is used to open the camera. This method takes as parameters the implementation of the UnicoSelfie class and the JSON with the credentials, generated in the previous step.

The following example illustrates the steps for configuring the listeners and opening the camera:

_opener.openCameraSelfie(jsonFileName: androidJsonFileName, listener: this)

Making a POST Request to the Client API


For security reasons, the interval between the generation of the encrypted and its sending via one of the available flows must be a maximum of 10 minutes. Submissions made beyond this period will be automatically rejected by the API.


When invoked, the method receives a parameter of type UnicoError, which contains details about the error. Learn more about the UnicoError type in the SDK's documentation.

If you need to convert base64 to bitmap, the standard method doesn't work for Android. It is necessary to perform a split at the comma (,) for it to work. If you want to know more, read the article:

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 REST APIs of by Client. 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 .

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