DocumentDetector v7.x and above
Requirements
Flutter | Version |
---|---|
Flutter | 1.20+ |
Dart |
|
Android | Version |
---|---|
minSdk | 21 |
compileSdk | 33 |
iOS | Version |
---|---|
iOS Target | 12.0 |
Xcode | 14.3.1+ |
Swift | 5.3.2+ |
Native SDKs dependencies
Runtime permissions
These are the Android's runtime permissions:
Permission | Reason | Required |
---|---|---|
| To capture photos of the documents | Only required in camera capture stream |
| To access the device external storage and select documents in the upload flow | Only required in the upload stream |
| To access the device media storage and select documents in the upload flow | Only required in the upload stream |
| To collect connection data with the signal tower, for analytical purposes only | No |
Platform Configurations
If your version of Gradle is earlier than 7, add these lines to your build.gradle
.
If your version of Gradle is 7 or newer, add these lines to your settings.gradle
.
Add support for Java 8 (skip this code if Java 8 is enabled), Data Binding and TensorFlow Model to your build.gradle
file.
As our SDKs activities use Data Binding, it is required that you enable this setting within your app. The compileOptions
setting is required for SDK's built-in lambda functions, which were released in Java 8. The noCompress
setting tells the compiler not to compress files with the .tflite
extension used in the DocumentDetector.
To customize the primary color of the SDK, you need to ensure that the Material Design library is imported in your app. Add the following dependency to your build.gradle file:
Supported Documents
Currently, supported documents are:
Instantiating the SDK
To create a DocumentDetector
instance, two required parameters must be provided:
Parameter | Description |
---|---|
| Usage token associated with your CAF account |
| Defines the document capture flow. Create a |
DocumentCaptureFlow
Each DocumentCaptureFlow
element from the list will be a capture step.
The DocumentCaptureFlow
class have the following configurations:
DocumentType documentType
DocumentType documentType
Identifies which document will be requested for capture in the respective step. You can choose from the Supported Documents list.
InstructionalPopupSettingsAndroid? androidCustomization
InstructionalPopupSettingsAndroid? androidCustomization
Customize the instructional popup document illustration and label for Android devices.
Parameter | Description |
---|---|
| Change the document label displayed in the popup. To customize this, you just have to provide a |
| Change the document illustration displayed in the popup. To customize this, you must provide the |
InstructionalPopupSettingsIOS? iOSCustomization
InstructionalPopupSettingsIOS? iOSCustomization
Customize the instructional popup document illustration and label for iOS devices.
Parameter | Description |
---|---|
| Change the document label displayed in the popup. To customize this, you just need to provide a |
| Change the document illustration displayed in the popup. To customize this, you must provide the name of the |
Implementation Example
This is an example of how to instantiate the SDK and capture its results:
DocumentDetector options
DocumentDetectorEvent Results
DocumentDetectorEvent
is an abstract class representing different types of events.
It is used to create an instance of one of the event subclasses based on a map input, which comes from the SDK's result.
Depending on the event type, it creates an instance of either DocumentDetectorEventClosed
, DocumentDetectorEventSuccess
, or DocumentDetectorEventFailure
. If the event is not recognized, it throws an internal exception.
This setup allows for a structured and type-safe way to handle different outcomes of the document capture process in the SDK.
DocumentDetectorEventClosed
DocumentDetectorEventClosed
This class represents an event where the document capture was closed by the user, either by pressing the close button at the top right, or sending the app to the background.
DocumentDetectorEventSuccess
DocumentDetectorEventSuccess
This class represents a successful document capture event. The user document has been successfully captured, and the URLs for download the captures have been returned. It includes:
String? documentType
String? documentType
The type of the document captured
String? trackingId
String? trackingId
An ID for tracking the capture execution.
DocumentDetectorEventFailure
DocumentDetectorEventFailure
This class represents a failure in the document capture process. The user document hasn't been successfully captured, the errorType
and errorMessage
parameter contains the failure reason. It includes:
String? errorType
String? errorType
Information on the type of error returned by the SDK. Below are the types of errors and their causes:
Type | Reason | Example |
---|---|---|
| The SDK is not yet available for use. The | The device's internal storage is full when installing the app, and the face detection template cannot be installed together. |
| The token entered is not valid for the corresponding product. | If you are using an expired or non-existent token. |
| When an SDK internal library cannot be started. | Forgetting to set the |
| Internet connection failure. | User was without internet during the SDK execution. |
| You are missing some mandatory permission to run the SDK. | Start SDK without camera permission granted. |
| When the SDK cannot be started due to a security reason. | When the device is rooted. See security error code for more reasons. |
| When an SDK request receives a status code of failure. | If an internal API is unstable. |
| There is no space on the user device's internal storage. | When there is no space on the internal storage while capturing the document photo. |
String? errorMessage
String? errorMessage
A message describing the error.
int? securityErrorCode
int? securityErrorCode
An error code specific to Android, indicating the type of security validation failure:
100
- blocking emulated devices;200
- blocking rooted devices;300
- blocking devices with developer options enabled;400
- blocking devices with ADB enabled;500
- blocking devices with debugging enabled;
Last updated