FaceLiveness
The @caf.io/react-native-face-liveness library is a powerful tool for integrating facial liveness detection functionality into React Native applications. It allows developers to easily incorporate liv
Requirements
The libraries are compatible only with React Native versions that are 0.73.x
or later.
Android
Settings | Minimum version |
---|---|
minSdkVersion | 21 |
compileSdkVersion | 34 |
Java version | 8 |
To publish your app on the Google Play Store, you must complete a data safety form. Since we integrate with the FingerPrintJS SDK, you'll need to provide the following information:
Question in Google Play Console's data safety form | Response |
---|---|
Does your app collect or share any of the required user data types? | Yes. |
What type of data is collected? | Device or other identifiers. |
Is this data collected, shared, or both? | Collected. |
Is this data processed ephemerally? | Yes. |
Why is this user data collected? | Fraud Prevention, Security, and Compliance. |
iOS
Settings | Minimum version |
---|---|
Target | 13.0+ |
Xcode | 15.4+ |
Swift | 5.5+ |
Installation
Android
If you're utilizing Expo for your project, be sure to include that line in android/build.gradle
.
iOS
In the Podfile in the iOS folder, add this following sources:
After editing your Podfile, save it and install the SDK along with its dependencies by running the following command:
Usage
Methods
startFaceLiveness
This method inicialize the face liveness.
Params
Param | Type | Required | Description |
---|---|---|---|
mobileToken | string | Yes | Usage token associated with your Identity account |
personId | string | Yes | User CPF |
Hooks
useFaceLiveness
This hook provides the responses of method startFaceLiveness
and make the settings for face liveness.
Params
Param | Type | Required | Description |
---|---|---|---|
settings | FaceLivenessSettings | No | Settings for the face liveness |
Responses
Types
FaceLivenessResult
Name | Type | Description |
---|---|---|
signedResponse | string | Signed response from the CAF server confirming that the captured selfie has a real face. This parameter is used to get an extra layer of security, checking that the signature of the response is not broken, or caused by request interception. If it is broken, there is a strong indication of request interception. |
signedResponse params
Name | Type | Description |
---|---|---|
requestId | string | Request identifier. |
isAlive | boolean | Validation of a living person, identifies whether the user passed successfully or not. |
token | string | Request token. |
userId | string | User identifier provided for the request. |
imageUrl | string | Temporary link to the image, generated by our API. |
personId | string | User identifier provided for the SDK. |
sdkVersion | string | Sdk version in use. |
iat | string | Token expiration. |
FaceLivenessError
Name | Type | Description |
---|---|---|
message | string | Error message |
error | Error enum |
FaceLivenessResponse
Name | Type | Description |
---|---|---|
result | FaceLivenessResult or null | Shows when face liveness returns a successful capture |
error | FaceLivenessError or null | Shows when the face livenes return some error |
cancelled | boolean | Shows when user cancel the liveness |
isLoading | boolean | Shows when the face liveness is loading |
FaceLivenessSettings
Name | Type | Description | Android | iOS |
---|---|---|---|---|
cafStage | Used to redirect the SDK to the desired stage in caf api. | ✅ | ✅ | |
filter | Used to change the SDK filter. | ✅ | ✅ | |
imageUrlExpirationTime | Used to customize the image URL expiration time. | ✅ | ✅ | |
enableScreenshots | boolean | Used to enable screenshots during the SDK scan. Disabled by default for security reasons. | ✅ | ✅ |
loadingScreen | boolean | Used to enable a default loading progressbar during loading events. | ✅ | ✅ |
certificates | string[] | Used to set pinned certificates for reverse proxy implementation. | ✅ | ❌ |
faceLivenessBaseUrl | string | Used to enable the use of reverse proxy to execute face liveness. If used, the certificates must be set with the setCertificates method. | ✅ | ❌ |
authenticationBaseUrl | string | Used to enable the use of reverse proxy to execute SDK's authentications. | ✅ | ❌ |
Enums
Stage
Enum | Description |
---|---|
BETA | Beta environment |
PROD | Production environment |
Filter
Enum | Description |
---|---|
LINE_DRAWING | Alternative mask for face liveness |
NATURAL | Normal mask for face liveness |
Time
Enum | Description | Android | iOS |
---|---|---|---|
THREE_HOURS | Image url expiration time expires in three hours | ✅ | ✅ |
THIRTY_DAYS | Image url expiration time expires in thirty days | ✅ | ✅ |
THIRTY_MIN | Image url expiration time expires in thirty minutes | ❌ | ✅ |
Error
Enum | Description | Android | iOS |
---|---|---|---|
ServerException | Indicates an exception occurred on the server-side. This error is typically returned when there is an issue with the server processing the facial recognition request. This could include server-side errors, misconfigurations, or service interruptions. | ✅ | ✅ |
NetworkException | Indicates a network-related error occurred. This error may occur due to various network issues such as a lack of internet connection, server timeouts, or network congestion. | ✅ | ✅ |
UnknownException | An unknown error has occurred. The associated string will contain further information about the error. These errors should be reported to iProov for further investigation. | ✅ | ✅ |
CameraPermission | Indicates that the device does not have permission to access the camera. This error typically occurs when the user denies access to the camera or if the app lacks the necessary permissions. | ✅ | ✅ |
TokenException | Indicates that the device does not have permission to access the camera. This error typically occurs when the user denies access to the camera or if the app lacks the necessary permissions. | ✅ | ✅ |
UnsupportedDevice | Indicates that the device is not supported. This error may occur if the device hardware or software does not meet the minimum requirements for facial recognition functionality. | ✅ | ✅ |
CertificateException | Indicates an exception occurred on certificate pinning. This error may occur when the provided certificates on the reverse proxy implementation are not right. | ✅ | ❌ |
Last updated