Receiving the result
The SDK returns the capture result through the callback object passed to open(). Both success and error handlers are mandatory.
Selfie capture
success (selfie)
Called when the image is captured successfully. Receives an object with:
base64— captured image; can be used to display a preview in your application.encrypted— JWT payload that must be sent to your backend to complete biometric validation via the REST API.
const callback = {
on: {
success: (obj) => {
const base64 = obj.base64;
const encrypted = obj.encrypted; // JWT to send to your backend
},
error: (error) => {
console.error(error);
}
}
};
encrypted usage- The
encryptedattribute is strictly intended for sending the image through the by Client APIs. It must not be opened or serialized — its characteristics may change without prior notice. Unico is not responsible for any damages resulting from improper handling. - The
base64/encryptedfiles may vary in size depending on device quality, generated photo size, and Unico's business rules. Do not limit the size of the string generated by the SDK in your programming logic or infrastructure.
error (selfie)
Called when an error occurs during capture. Receives an ErrorBio object with getCode() and getDescription(). See Error handling for the full list of error codes.
error: (error) => {
const code = error.getCode();
const description = error.getDescription();
}
Document capture
success (document)
Called when the document image is captured successfully. Receives an object with:
base64— captured image; can be used to display a preview.encrypted— JWT payload that must be sent to your backend within 10 minutes and must never be modified or deserialized.
const callback = {
on: {
success: (obj) => {
const base64 = obj.base64;
const encrypted = obj.encrypted;
},
error: (error) => { /* ... */ }
}
};
error (document)
Called when an error occurs during document capture. Receives an ErrorBio object. See Error handling for the full list of error codes.