DocumentDetector

The @caf.io/react-native-document-detector library is responsible for capturing identity documents, such as the ID (Brazilian General Registry - RG), Drivers License (CNH), National Foreigner Registry

Requirements

The libraries are compatible only with React Native versions that are 0.66.5 or later.

Android

iOS

Installation

yarn add @caf.io/react-native-document-detector
# or 
npm install @caf.io/react-native-document-detector

Android

Inside the android folder in app/build.gradle add the following code:

android {
  ...
  buildFeatures {
    dataBinding = true
  }
}

iOS

In the Podfile in the iOS folder, add this following sources:

source 'https://github.com/combateafraude/iOS.git'
source 'https://cdn.cocoapods.org'

After editing your Podfile, save it and install the SDK along with its dependencies by running the following command:

pod install

Usage

import React from 'react';
import { View, Button, StyleSheet } from 'react-native';
import {
  startDocumentDetector,
  useDocumentDetector,
  DocumentDetectorOptions,
  Stage,
  Document,
} from '@caf.io/react-native-document-detector';

export default function App() {
  const mobileToken: string = "";
  const personId: string = "";

  const options: DocumentDetectorOptions = {
    personId,
    cafStage: Stage.PROD, // optional
    documentSteps: [Document.RG_FRONT, Document.RG_BACK], // required
  }

  const { 
    result, 
    error, 
    cancelled, 
  } = useDocumentDetector(options);

  return (
    <View style={styles.container}>
      <Button 
        title="Press" 
        onPress={() => startDocumentDetector(mobileToken)} 
      />
    </View>
  );
} 

const styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    justifyContent: 'center',
  },
});

Methods

startDocumentDetector

This method inicialize the document detector.

Params

Hooks

useDocumentDetector

This hook provides the responses of method startDocumentDetector and make the settings for document detector.

Params

Responses

DocumentDetectorResponse

Types

DocumentDetectorResult

DocumentDetectorCapture

DocumentDetectorError

DocumentDetectorResponse

DocumentDetectorSettings

DocumentDetectorUploadSettings

DocumentDetectorMessageSettings

DocumentDetectorSecuritySettings

Enums

Document

FileFormat

Stage

Error

Last updated

Logo

2023 Β© Caf. - All rights reserved