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
Atualizado
Isto foi útil?
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
Atualizado
Isto foi útil?
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.
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:
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:
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:
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.
onUserClosedCameraManually()
This method is invoked whenever the user manually closes the camera, such as by clicking the "Back" button.
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.
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.
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:
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.
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:
onSuccessSelfie
MethodWhen successfully capturing an image, this method is invoked and returns an object of type SelfieResult
, which is later used in the REST API calls.
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
MethodWhen an error occurs during the image capture, this method is invoked and returns an object of type ErrorBio
:
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:
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.
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:
If any error occurs while preparing the camera, the onCameraFailed
event is triggered. You should implement this method applying your app's business rules.
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 .