Document Capture
In this section, you will find all the necessary information for using and integrating the Unico IDCloud SDK into your Flutter applications for document capture
Atualizado
In this section, you will find all the necessary information for using and integrating the Unico IDCloud SDK into your Flutter applications for document capture
Atualizado
Institucional
Sobre nósCopyright © 2024 unico. All rights reserved
This guide has been designed to help you implement the Flutter SDK quickly and easily. Below, you will find a step-by-step process for the entire integration. After that, if you wish to customize the experience, be sure to check the Flutter Customization section.
In this camera mode, there is a capture frame to assist the user in positioning the document correctly. Once the document is properly positioned, the user must click the button to take a photo of the document.
The SDK does not perform any validation of what is being captured.
In this camera mode, it is possible to capture the following documents:
CPF: Capture the front of the CPF;
CNH: Capture the open CNH;
CNH Front: Capture the front of the CNH;
CNH Back: Capture the back of the CNH;
RG Front: Capture the front of the RG;
RG Back: Capture the back of the RG;
Others: Capture any other document.
To get started, create an instance of the builder (generated through the UnicoCheckBuilder
interface), providing the relevant context and the implementation of the UnicoListener
class as parameters.
The implementation of this class is straightforward and can be done with just a few lines of code. All you need to do is override the callback methods with the business logic of your application.
Note that, as in the previous example, the implementation work of the UnicoListener
class is largely about configuring the callback methods. Each method is called in a specific situation based on the SDK's response.
Override the methods exemplified above with your application’s business logic.
onErrorUnico(UnicoError error)
This method is invoked with a parameter of type ErrorBio
that contains details about the error. Learn more about the ErrorBio
type in the error handling section.
onUserClosedCameraManually()
EThis method is invoked whenever the user manually closes the camera, such as by clicking the "Back" button.
onSystemClosedCameraTimeoutSession()
This method is invoked once the maximum session time is reached (without capturing any image).
You can configure the session timeout in seconds using setTimeoutSession
. The default and minimum timeout is 40 seconds.
onSystemChangedTypeCameraTimeoutFaceInference()
This method is invoked when the maximum time for face detection is reached without detection.
The maximum time is 13 seconds. The mode is then switched to manual capture to facilitate the user’s action.
All the above methods must be created as indicated in your project (even without any logic); otherwise, the project won’t compile successfully.
The implementation of these listener methods should be done through an instance of the iAcessoBioSelfie
class.
The camera open method needs to know what to do when an image is successfully captured or when an error occurs during the process. The camera's behavior is informed through the deployment of listeners, which are invoked in both success and error scenarios.
By implementing the listeners, you can specify what happens in your app in the event of an error (e.g., the onErrorDocument
method) or success (e.g., the onSuccessDocument
method) during the image capture process.
onSucessDocument
MethodWhen successfully capturing an image, this method is invoked and returns an object of type ResultCamera
, which is used later in the REST API requests:
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.
If it is necessary to convert the base64 string to a bitmap, the standard method does not work for Android. You need to perform a split at the comma (,) for it to function correctly. If you want to learn more, read the article: How to convert a Base64 string into a Bitmap image to show it in a ImageView?.
onErrorDocument
MethodIf an error occurs during the image capture, this method is invoked and returns an object of typeUnicoError
:
Learn more about the types of ErrorBio
in the SDK's error handling section.
To open the camera, the openCameraDocument()
method is used. This method is made available through the object generated by an instance of the UnicoCheck
class.
This method accepts the following parameters:
A JSON file containing the credentials, generated in the credentials configuration step.
The listeners configured above.
The type of document to be captured, which can be one of the following:
Parameter | Description |
---|---|
| Capture the front of the CPF |
| Capture the open CNH |
| Capture the front of the CNH |
| Capture the back of the CNH |
| Capture the front of the RG |
| Capture the back of the RG RG |
| Capture any other document |
If you need to capture a document for which there is no specific frame (e.g., RNE, among others), use the DocumentCameraTypes.OUTROS("descrição")
frame, which will allow you to use a generic rectangular frame to guide any capture.
Example using the open CNH:
After capturing images, the next step is to send the generated base64
image from the SDK to the Client APIs.
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 Help Center.