Usage and Integration Guide

Initializing the SDK

Create an instance of the builder (generated through the IAcessoBioBuilder interface), providing the context and environment as parameters, along with the implementation of the AcessoBioListener class.

The implementation of this class is quite simple and can be done in just a few lines of code. All you need to do is instantiate the builder by providing the relevant context and override the callback methods with the business logic of your application:

internal class MainActivity : AppCompatActivity() {

    private val acessoBioListener = object : AcessoBioListener {
        override fun onErrorAcessoBio(errorBio: ErrorBio?) { }
    
        override fun onUserClosedCameraManually() { }
    
        override fun onSystemClosedCameraTimeoutSession() { }
    
        override fun onSystemChangedTypeCameraTimeoutFaceInference() { }
    }

    private val acessoBioBuilder: IAcessoBioBuilder = AcessoBio(this, acessoBioListener)
}

Environment configuration

Configure the environment that will be used during the SDK execution. Use the Environment enum, which contains the following options:

  • Environment.PROD: for production environment;

  • Environment.UAT: for approval environment.

See how to implement it in the example below:

Implementing Callback Functions

Note that the work of implementing the AcessoBioListener class is, for the most part, configuring the callback methods. Each method is called in a specific situation based on the SDK's return.

Simply override the methods shown in the previous step with your application's business logic.

This method is invoked whenever any implementation error occurs while using one of our methods:

1

onErrorAcessoBio(ErrorBio errorBio)

When invoked, the method receives a parameter of type ErrorBio that contains details about the error. Learn more about the ErrorBio type in the error handling section.

2

onUserClosedCameraManually()

This method is invoked whenever the user manually closes the camera, such as when clicking the "Back" button.

3

onSystemClosedCameraTimeoutSession()

This method is invoked as soon as the maximum session time is reached (without capturing any image).

circle-exclamation

4

onSystemChangedTypeCameraTimeoutFaceInference()

This method is invoked as soon as the maximum time for face detection is reached (without detecting anything). In this case, the camera mode is automatically switched to manual capture mode (without the smart capture outline).

circle-exclamation

triangle-exclamation

Implementing Listeners for Camera Events

circle-info

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

The camera opening method, which is called in the next step, needs to know what to do when it successfully captures an image or when an error occurs in the process. It is necessary to inform "what to do" to the camera opening method by implementing listeners that are called in cases of success or error.

Through the configuration of the listeners, you can specify what happens in your app in error situations (onErrorSelfie method) or success situations (onSuccessSelfie method) during image capture.

To configure the listeners, it is necessary to implement:

Prepare and open the camera

To proceed with opening the camera, it is first necessary to prepare it using the prepareCamera method. This method receives as parameters the implementation of the CameraListener class.

When the camera is prepared, the onCameraReady event is triggered, which receives an object of type UnicoCheckCameraOpener.Camera as a parameter.

It is necessary to override this method, opening the camera with the object received through the open() method. The open() method should receive as parameters the listeners configured in the previous steps.

Since we have two integration flows (one native and one via webApp), there is a difference in the method used as a trigger to start the capture flow.

For integration with the webApp flow, the implementation is as follows:

circle-exclamation

onSucessSelfie Method

circle-info

This method is mandatory, since the interface is used in integration by Client. In the context of Unico, it does not return the result of the operation directly; therefore, it is necessary to use the onSuccess method, detailed below.

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

The SuccessResult object returns one attribute: processId:

  • The processId attribute can be used to obtain information about the previously created process.

onSucess Method

circle-exclamation

Upon successfully completing the flow in the WebApp, this method is invoked and returns an object of type SuccessResult, which is later used in the REST API call:

The SuccessResult object returns one attribute: processId.

  • The processId attribute can be used to query the result of the customer validation process.

onErrorSelfie Method

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

Last updated

Was this helpful?