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
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.
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 must 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.
To get started with the Unico IDCloud iOS SDK, import the SDK and implement the AcessoBioManagerDelegate
interface in 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 while providing the appropriate context and override the callback methods with the business logic of your application.
Note that, as in the previous example, the implementation work for the AcessoBioManagerDelegate
interface mainly involves configuring the callback methods. Each method is called in a specific situation based on the SDK's return status.
Override the methods exemplified above with your application’s business logic.
onErrorAcessoBioManager(_ error: ErrorBio!)
This method is invoked whenever any implementation error occurs using any SDK method. It receives an ErrorBio
parameter that contains error details. See the Error Handling section for more about ErrorBio
.
onUserClosedCameraManually()
This method is invoked when the user manually closes the camera, such as by clicking the "Back" button.
onSystemClosedCameraTimeoutSession()
This method is invoked when the maximum session time is reached (without capturing an 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 method to open the camera (which is called in the next step) needs to know what to do when an image is successfully captured or if there is an error in the process. You specify "what to do" to the camera opening method through the configuration of delegates that are invoked in success or error situations.
By configuring the delegates, you can define the behavior of your app in case of an error (using the onErrorDocument
method) or success (using the onSuccessDocument
method) during image capture.
To set up the delegates, you should implement the DocumentCameraDelegate
and AcessoBioDocumentDelegate
interfaces:
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
If an error occurs during the image capture, this method is invoked and returns an object of type ErrorBio
:
Learn more about the types of ErrorBio
in the SDK's error handling section.
To open the camera, it is necessary to prepare it using the prepareDocumentCamera
method. This method takes as parameters the implementation of the DocumentCameraDelegate
class and the JSON with the credentials, generated in the previous step.
When the camera is ready, the onCameraReadyDocument
event is triggered, which receives a parameter of type AcessoBioCameraOpenerDelegate
. You should override this method to open the camera using the object received through the openDocument()
method, receiving the parameters for the type of document to be captured, which are:
If you need to capture a document for which there is no specific frame (e.g., RNE, among others), use the DocumentEnums.none
frame, which will allow you to use a generic rectangular frame to guide any capture.
The delegates implemented above (described here as Self):
The ErrorPrepare
type is an extension of ErrorBio
, thus containing all its properties. Learn more about the ErrorBio
type in the error handling section of the SDK.
If an error occurs while preparing the camera, the onCameraFailedDocument
event is triggered. You should implement this method according to your app's business logic. In case of success, the onSuccessDocument
event is triggered, as explained in the section above.
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.
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