DocumentDetector v7.x and above
Requirements
Flutter
1.20+
Dart
>=2.15.0 <4.0.0
minSdk
26
compileSdk
34
iOS Target
13.0+
Xcode
15.4+
Swift
5.3.2+
Native SDKs dependencies
Runtime permissions
These are the Android's runtime permissions:
CAMERA
To capture photos of the documents
Only required in camera capture stream
READ_EXTERNAL_STORAGE
To access the device external storage and select documents in the upload flow. This permission is only required for versions lower than API33
Only required in the upload stream
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), and TensorFlow Model to your build.gradle
file.
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:
mobileToken
Usage token associated with your CAF account
captureFlow
Defines the document capture flow. Create a List<DocumentCaptureFlow>
to configure each capture step.
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.
String? documentLabel
Change the document label displayed in the popup. To customize this, you just have to provide a String
element.
String? documentIllustration
Change the document illustration displayed in the popup. To customize this, you must provide the name
of the file with the custom illustration you created in the res/drawable
folder of your Android app.
InstructionalPopupSettingsIOS? iOSCustomization
InstructionalPopupSettingsIOS? iOSCustomization
Customize the instructional popup document illustration and label for iOS devices.
String? documentLabel
Change the document label displayed in the popup. To customize this, you just need to provide a String
element.
String? documentIllustration
Change the document illustration displayed in the popup. To customize this, you must provide the name of the Image Set
with the custom illustration you created in the Asset Catalog
of you iOS app.
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:
AvailabilityReason
The SDK is not yet available for use. The errorMessage
parameter will bring more instructions.
The device's internal storage is full when installing the app, and the face detection template cannot be installed together.
InvalidTokenReason
The token entered is not valid for the corresponding product.
If you are using an expired or non-existent token.
LibraryReason
When an SDK internal library cannot be started.
Forgetting to set the aaptOptions
noCompress configuration will lead to this failure in the DocumentDetector.
NetworkReason
Internet connection failure.
User was without internet during the SDK execution.
PermissionReason
You are missing some mandatory permission to run the SDK.
Start SDK without camera permission granted.
SecurityReason
When the SDK cannot be started due to a security reason.
When the device is rooted. See security error code for more reasons.
ServerReason
When an SDK request receives a status code of failure.
If an internal API is unstable.
StorageReason
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