In this section, you will find all the necessary information for using and integrating the Unico IDCloud platform SDK into your Webapplications
In this section, you will find all the necessary information for using and integrating the Unico IDCloud platform SDK into your Web applications for selfie capture
This guide has been designed to help you quickly and easily implement the Web 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 Web Customization section.
To get started, follow these 3 simple steps in your project:
Instantiate a new Builder:
Specify the path of additional files (if added to your project):
Specify the path of the AI model files if you are using the Smart Camera functionality:
Starting from version 3.18.0, to have the SDK automatically fetch additional resources, simply omit the setResourceDirectory
method and ensure the CSP settings are correctly applied for SDK usage.
By default, the SDK Web uses the production environment.
It is possible to configure which environment will be used during SDK execution. Use the SDKEnvironmentTypes
enumeration, which includes the following options:
SDKEnvironmentTypes.PROD
: for the Production environment;
SDKEnvironmentTypes.UAT
: for the Staging environment.
Here is an example of how to implement it:
One of the objects that must be passed as a parameter to the method responsible for rendering the capture frame is the callback object. This object should contain callback functions for success and error cases, as shown below:
his object is mandatory, and if not implemented correctly (covering all success or error events), it will throw an exception that, if not handled, will be displayed in the user's console.
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 must be exclusive to interactions with the APIs to ensure the integrity and security of the data. Unico is not responsible for any damages arising from this practice, as modifications may occur unexpectedly.
The base64
and encrypted
files can vary in size due to several factors, including the quality of the devices and the photos generated, as well as Unico's business rules. To avoid issues in your application, do not restrict the size of the string generated by the SDK for these files in your programming logic or infrastructure.
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?.
To start the camera with the settings made so far, you need to create an instance of the builder using the build()
method.
Then, once the camera is "built", you need to configure the camera capture mode.
The camera setup will be done through the prepareSelfieCamera()
method available from the builder. This method takes 2 parameters:
The UnicoConfig
class obtained in this step;
The desired camera mode, which can be:
SelfieCameraTypes.NORMAL
for normal camera mode;
SelfieCameraTypes.SMART
for smart camera mode.
This method returns a promise that, when resolved, provides an object used to actually open the camera through the open
method, which takes the callback functions as parameters.
To optimize camera startup, you can separate the calls to the prepareSelfieCamera()
and open()
methods.
To use automatic capture, pass the Unico.SelfieCameraTypes.SMART
parameter to the prepareSelfieCamera
method.
For smart capture, the computer vision models must also be loaded through the setModelsPath
method, as explained in the first step of this guide.
Using the UnicoConfig
class:
It is possible to use the SDK Web with Interactive Liveness embedded in an iFrame. To do this, follow a similar implementation to the previous section in preparing the camera.
The camera setup will be done through the prepareSelfieCameraForIFrame()
method, also available from the builder. This method takes the same parameters as prepareSelfieCamera()
:
The prepareSelfieCameraForIFrame()
method only works if the implementation is within an iFrame. Using it outside of an iFrame results in error 73724. Similarly, using prepareSelfieCamera()
within an iFrame also results in error 73724.
For the capture to work correctly, the <iframe>
element must be implemented as shown below:
To execute the capture, the browser must be in fullscreen mode so that the SDK can automatically resize itself. Therefore, when starting the capture, the SDK will display a screen requesting the frame to open in fullscreen mode. See the following example:
After allowing fullscreen usage, the capture frame will open normally:
Apple restricts the use of fullscreen APIs specifically on iPhones (iPads are acceptable). Therefore, for captures on iPhones, it is necessary to configure the positioning of the iFrame manually.
After capturing images, the next step is to send the generated encrypted
image from the SDK to the Client APIs.
For security reasons, the interval between the generation of the encrypted data and the sending through one of the available flows must be no more than 10 minutes. Submissions made beyond this period will be automatically rejected by the API.
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.
In this section, you will find all the necessary information for using and integrating the Unico IDCloud SDK into your Web applications for document capture
This guide has been designed to help you implement the Web 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 Web 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, you need to perform 2 simple steps in your project:
Instantiate a new Builder:
Specify the path for additional files (if added to your project):
It is recommended that you configure the size of the frame within your application to optimize the capture area within your WebApp. Below is how to configure this for both Web Desktop and Mobile.
The functionality of the frame can often be affected by certain design systems that have some type of grid system, such as Bootstrap or Material-UI. To minimize this risk, make sure to position the frame (id="box-camera") in a part of the code that does not inherit unwanted CSS rules.
For Web Desktop versions, it is possible to restrict the size of the frame so that it does not take up the entire dimension of your WebApp. To do this, simply wrap the frame (id="box-camera") in another HTML tag, as shown below:
Ideally, you should try to maintain an appropriate aspect ratio between height and width, which will make it easier to frame the user's face. Here’s an example:
Following the example above, the frame respects the size of the parent element, represented here by the container. This way, you have the flexibility to implement the frame in the most convenient manner for your application (such as in a modal, for example).
Testing by resizing the screen through your browser's developer mode does not work. It is recommended that this type of testing be done by resizing the window of your browser.
For a Web Mobile view, it is recommended that the capture frame occupies 100% of the screen to avoid issues with computer vision algorithms. If the capture area is distorted, the automatic capture functionality (Smart Camera) may experience problems with face tracking calculations.
Therefore, it is recommended that in the Web Mobile view:
The capture frame occupies 100% of the device screen (100vw/vh);
Avoid horizontal or vertical scrolling (this can be minimized with a modal);
Testing devices using your browser's developer mode does not work, as the camera used by your browser is the same as that of your desktop, which has a completely different resolution than a mobile device's camera. We recommend that this type of testing be conducted directly on the device.
One of the objects that must be passed as a parameter to the method responsible for rendering the capture frame is the callback object. This object should contain callback functions for success and error cases, as exemplified below:
This object is mandatory, and if it is not correctly implemented (covering all success or error events), it will generate an exception, which, if unhandled, will be displayed in the user's console.
To start the camera with the configurations made so far, you need to create an instance of the builder using the build()
method:
Next, with the camera "assembled," you need to configure the capture mode of the camera. The camera preparation is done using the prepareDocumentCamera()
method, provided by the builder. This method takes 2 parameters:
The UnicoConfig
class obtained in this step;
The type of document to be captured.
This method returns a promise that, when resolved, returns an object that is used to actually open the camera through the open
method, which takes the callback functions configured in the step above as a parameter.
Below is an example using the capture of a driver's license (CNH): Using the UnicoConfig
class:
If you need to capture a document for which there is no specific frame (e.g., RNE, among others), use the DocumentCameraType.None
frame, which will allow you to use a generic rectangular frame to guide any capture.
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 |
---|---|
DocumentCameraTypes.CPF
Capture the front of the CPF
DocumentCameraTypes.CNH
Capture the open CNH
DocumentCameraTypes.CNH_FRENTE
Capture the front of the CNH
DocumentCameraTypes.CNH_VERSO
Capture the back of the CNH
DocumentCameraTypess.RG_FRENTE
Capture the front of the RG
DocumentCameraType.RG_VERSO
Capture the back of the RG
DocumentCameraTypes.RG_FRENTE_NOVO
Capture the front of the new RG
DocumentCameraTypes.RG_VERSO_NOVO
Capture the back of the new RG
DocumentCameraTypes
.OTHERS("descrição")
Capture any other document