DocumentDetector v7.x and above
Last updated
Last updated
2023 © Caf. - All rights reserved
Flutter | Version |
---|---|
Android | Version |
---|---|
iOS | Version |
---|---|
These are the Android's runtime permissions:
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:
Currently, supported documents are:
To create a DocumentDetector
instance, two required parameters must be provided:
Each DocumentCaptureFlow
element from the list will be a capture step.
The DocumentCaptureFlow
class have the following configurations:
DocumentType documentType
Identifies which document will be requested for capture in the respective step. You can choose from the Supported Documents list.
InstructionalPopupSettingsAndroid? androidCustomization
Customize the instructional popup document illustration and label for Android devices.
InstructionalPopupSettingsIOS? iOSCustomization
Customize the instructional popup document illustration and label for iOS devices.
This is an example of how to instantiate the SDK and capture its 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
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
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
The type of the document captured
String? trackingId
An ID for tracking the capture execution.
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
Information on the type of error returned by the SDK. Below are the types of errors and their causes:
String? errorMessage
A message describing the error.
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;
Permission | Reason | Required |
---|---|---|
Permission | Reason | Required |
---|---|---|
Permission | Reason | Required |
---|---|---|
Parameter | Description |
---|---|
Parameter | Description |
---|---|
Parameter | Description |
---|---|
Type | Reason | Example |
---|---|---|
Type | Reason | Example |
---|---|---|
Flutter
1.20+
Dart
>=2.15.0 <4.0.0
minSdk
21
compileSdk
33
iOS Target
12.0
Xcode
14.3.1+
Swift
5.3.2+
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
Only required in the upload stream
READ_MEDIA_IMAGES
To access the device media storage and select documents in the upload flow
Only required in the upload stream
ACCESS_FINE_LOCATION
To collect connection data with the signal tower, for analytical purposes only
No
Privacy - Camera Usage Description
To capture the document photo(s)
Only required in camera capture stream
Privacy - Photo Library Usage Description
To perform the gallery opening
Required only in the upload stream
Privacy - Camera Usage Description
To capture the document photo(s)
Only required in camera capture stream
Privacy - Photo Library Usage Description
To perform the gallery opening
Required only in the upload stream
mobileToken
Usage token associated with your CAF account
captureFlow
Defines the document capture flow. Create a List<DocumentCaptureFlow>
to configure each capture step.
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.
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.
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.
InvalidTokenReason
The token entered is not valid for the corresponding product.
If you are using an expired or non-existent token.
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.
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.