@caf.io/react-native-face-liveness
About
Library for React Native
Minimum Requirements
Android
Settings | Minimum version |
---|
minSdkVersion | 21 |
compileSdkVersion | 33 |
Java version | 8 |
iOS
Settings | Minimum version |
---|
Target | 12 |
Xcode | 13.4.1 |
Getting Started
yarn add @caf.io/react-native-face-liveness
npm install @caf.io/react-native-face-liveness
Usage
TypeScript
import React from 'react';
import { View, Button, StyleSheet } from 'react-native';
import {
startFaceLiveness,
useFaceLiveness,
FaceLivenessOptions,
StageType,
FilterType,
TimeType
} from '@caf.io/react-native-face-liveness';
export default function App() {
const mobileToken: string = "";
const peopleId: string = "";
const options: FaceLivenessOptions = {
cafStage: StageType.PROD,
filter: FilterType.NATURAL,
imageUrlExpirationTime: TimeType.THREE_HOURS,
enableScreenshots: true,
loadingScreen: true
}
const {
result,
error,
cancelled,
isLoading
} = useFaceLiveness(options);
return (
<View style={styles.container}>
<Button
title="Press"
onPress={() => startFaceLiveness(mobileToken, peopleId)}
/>
</View>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
justifyContent: 'center',
},
});
Methods
startFaceLiveness
This method inicialize the face liveness.
Params
Param | Type | Default | Description |
---|
mobileToken | string | Required | Usage token associated with your Identity account |
peopleId | string | Required | User CPF |
Hooks
useFaceLiveness
This hook provides the responses of method startFaceLiveness
and make the settings for face liveness.
Params
Param | Type | Default | Description |
---|
options | FaceLivenessOptions | Optional | Settings for the face liveness |
Responses
FaceLivenessResponse
Types
FaceLivenessResponse
Name | Type | Description |
---|
result | string or null | Shows when face liveness returns a successful capture |
error | string 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 |
FaceLivenessOptions
Name | Type | Description |
---|
cafStage | StageType | Change the development environment |
filter | FilterType | Change face liveness mask |
imageUrlExpirationTime | TimeType | Change the expiration time of the face liveness url |
enableScreenshots | boolean | Toggle user screenshots |
loadingScreen | boolean | Toggle face liveness loading screen |
Enums
StageType
Enum | Description |
---|
BETA | Beta environment |
PROD | Production environment |
DEV | Development environment |
FilterType
Enum | Description |
---|
LINE_DRAWING | Alternative mask for face liveness |
NATURAL | Normal mask for face liveness |
TimeType
Enum | Description |
---|
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 |