Face Liveness
Install and launch Face Liveness for React Native. Learn prerequisites, CerttaLivenessConfiguration options, hook events, success and failure results, and error handling.
Prerequisites
Before proceeding, ensure the Certta SDK is properly installed. If you haven't done this yet, please refer to our Installation Guide.
Enable faceLiveness (and faceLivenessUI if you want the built-in UI) in caf-modules-config.json. You must include at least one liveness provider.
Starting Liveness
Use the useCafFaceLiveness hook and call open() with a CerttaLivenessConfiguration object. The hook subscribes to native events automatically — read results from the event state.
import { useEffect } from 'react';
import { useCafFaceLiveness } from '@caf.io/react-native-sdk';
function LivenessScreen() {
const { open, event } = useCafFaceLiveness();
useEffect(() => {
if (event.success) {
// Handle success — event.success.response is a JWT
} else if (event.failed) {
// Handle business failure — see Handling Failures
} else if (event.error) {
// Handle technical error
}
}, [event]);
const startLiveness = async () => {
try {
await open({
maxRetryAttempts: 3,
faceAuthEnabled: false,
showLoading: true,
useFaceLivenessUi: true,
});
} catch {
// Handle BRIDGE_EXCEPTION
}
};
// ...
}open() rejects with CerttaPlatformException and code BRIDGE_EXCEPTION when the native mapper rejects the configuration.
CerttaLivenessConfiguration parameters
maxRetryAttempts
3
Maximum retries after a failed capture attempt.
faceAuthEnabled
false
When enabled, the SDK performs face authentication.
showLoading
true
Shows loading indicators during processing when true.
useFaceLivenessUi
false
If enabled, the SDK uses the built-in Certta Face Liveness UI.
payFaceDebugMode
false
Enables debug mode for the PayFace provider. iOS only.
Understanding Liveness events and results
The hook event object has at most one populated field:
success (CerttaSuccess)
The capture and liveness pipeline succeeded. response is a JWT with the result data from the Liveness execution.
failed (CerttaLivenessFailure)
Liveness ran, but the outcome is a business failure.
type
CerttaLivenessFailureType.ImageCaptureFailure or CerttaLivenessFailureType.FaceRecognitionFailure.
cause
Identifier for diagnostics or UX messaging (for example TOO_DARK). Uppercased by the RN plugin.
description
Optional human-readable description from the native SDK.
response
Signed payload. Present for FaceRecognitionFailure when capture succeeded but recognition failed.
error (CerttaError)
Triggered when a technical blocker prevents the SDK from starting or finishing the process.
type
Error identifier mapped from the native SDK.
cause
Additional context for the failure, when present.
InitializationError
configure not called, empty token or user ID, or invalid maxRetryAttempts.
PermissionError
Camera (or related) permission denied.
NetworkError
Connectivity or server-side issues surfaced as network class errors.
SecurityError
Security checks failed.
UnknownError
Other failures not mapped to a specific case.
Cancelled
Occurs when the user abandons the flow before completion, such as by pressing the back button or sending the app to the background.
Atualizado

