Skip to main content

Get Started

In this guide you will learn step-by-step how to add ID Capture to your application.

note

Using ID Capture at the same time as other modes (e.g. Barcode Capture or Text Capture) is not supported.

The general steps are:

  • Creating a new Data Capture Context instance
  • Accessing a Camera
  • Configuring the Capture Settings
  • Implementing a Listener to Receive Scan Results
  • Setting up the Capture View and Overlay
  • Starting the Capture Process

Prerequisites

Before starting with adding a capture mode, make sure that you have a valid Scandit Data Capture SDK license key and that you added the necessary dependencies. If you have not done that yet, check out this guide.

note

You can retrieve your Scandit Data Capture SDK license key, by signing in to your Scandit account.

Internal dependencies

Some of the Scandit Data Capture SDK modules depend on others to work:

ModuleDependencies
scandit-react-native-datacapture-coreNo dependencies
scandit-react-native-datacapture-barcodescandit-react-native-datacapture-core
scandit-react-native-datacapture-parserscandit-react-native-datacapture-core
scandit-react-native-datacapture-textscandit-react-native-datacapture-core
scandit-react-native-datacapture-idscandit-react-native-datacapture-core scandit-react-native-datacapture-text(VIZ documents)

When adding ScanditIdCapture to a React Native project, certain native dependencies need to be added manually to your project, depending on the documents you want to scan:

  • If you’re only scanning barcode based documents, you only need to add the ScanditIdCapture React Native plugin.
  • If you’re scanning VIZ documents, you also need to add the ScanditOCR and ScanditTextCaptureBase native dependencies.
  • If you’re scanning MRZ documents, you also need the native ScanditTextCapture dependency.
tip

If you’re scanning both VIZ and MRZ documents you can add the ScanditTextCapture React Native (scandit-datacapture-react-native-text) plugin, which includes the native dependencies for both VIZ and MRZ documents.

Please note that your license may support only a subset of ID Capture features. If you would like to use additional features please contact us at Scandit Support.

Create the Data Capture Context

The first step to add capture capabilities to your application is to create a new data capture context. The context expects a valid Scandit Data Capture SDK license key during construction.

const context = DataCaptureContext.forLicenseKey(
'-- ENTER YOUR SCANDIT LICENSE KEY HERE --'
);

Add the Camera

You need to also create the Camera:

const camera = Camera.default;
context.setFrameSource(camera);

const cameraSettings = IdCapture.recommendedCameraSettings;

// Depending on the use case further camera settings adjustments can be made here.

if (camera != null) {
camera.applySettings(cameraSettings);
}

Create ID Capture Settings

Use IdCaptureSettings to configure the types of documents that you’d like to scan. Check IdDocumentType for all the available options.

const settings = new IdCaptureSettings();
settings.supportedDocuments = [
IdDocumentType.IdCardVIZ,
IdDocumentType.AAMVABarcode,
IdDocumentType.DLVIZ,
];

Implement the Listener

To receive scan results, implement IdCaptureListener. A result is delivered as CapturedId. This class contains data common for all kinds of personal identification documents. For more specific information use its non-null result properties (for example CapturedId.aamvaBarcodeResult).

const listener = {
didCaptureId: (idCapture, session) => {
if (session.newlyCapturedId.aamvaBarcodeResult != null) {
// Handle the information extracted.
}
},
didFailWithError: (idCapture, error, session) => {
// Handle the error.
},
};

Create a new ID Capture mode with the chosen settings. Then register the listener:

const idCapture = IdCapture.forContext(context, settings);
idCapture.addListener(listener);

Use a Capture View to Visualize the Scan Process

When using the built-in camera as frame source, you will typically want to display the camera preview on the screen together with UI elements that guide the user through the capturing process. To do that, add a DataCaptureView to your view hierarchy:

<DataCaptureView context={this.dataCaptureContext} ref={this.viewRef}>

Then create an instance of IdCaptureOverlay attached to the view:

let overlay = IdCaptureOverlay.withTextCaptureForView(
idCapture,
this.viewRef.current
);

The overlay chooses the displayed UI automatically, based on the selected IdCaptureSettings.

Turn on the Camera

Finally, turn on the camera to start scanning:

camera.switchToDesiredState(FrameSourceState.On);

And this is it. You can now scan documents.