DocumentDetector
Supported documents
Currently, the supported documents in Android are: RG, CNH, RNE, CRLV, CTPS, Passport. If you have any suggestions for other documents, please contact us!
Privacy Policy and Terms & Conditions of Use
When using our plugin, please make sure that you agree with our Privacy Policy and our Terms and Conditions of Use.
Analytics
Our SDKs by default collect information about the user and running environment to better map fraudsters and understand their behaviors. We recommend keeping this collection active as the sole purpose of this data is for fraud reduction, but if you wish you can disable it by the **.setAnalyticsSettings(bool useAnalytics)
** parameter.
Pre-requirements
Minimum configuration | Version |
Flutter | 1.12+ |
Dart | 2.12+ |
Minimum Android API | 21+ |
Compile SDK Version | 33 |
iOS | 11.0+ |
Xcode | 13.4.1+ |
If you use Dart in a version below 2.12, check the compatible version here.
Settings
Android
In the file ROOT_PROJECT/android/app/build.gradle
, add:
iOS
In the ROOT_PROJECT/ios/Podfile
, add to the end of the file:
Finally, add the permissions to the file ROOT_PROJECT/ios/Runner/Info.plist:
To enable text and voice in Portuguese, in your project, in the ROOTPROJECT/ios directory, open the .xcworkspace file in Xcode and add in Project > Info > Localizations the language Portuguese (Brazil).
Flutter
Add the plugin to your ROOT_PROJECT/pubspec.yaml
file:
Runtime Permissions
Permission | Motive | Required? |
| To capture the document photo(s) | Yes |
Utilization
Disabling Security Validations for Testing
We are constantly taking actions to make the product more and more secure, mitigating a number of attacks observed in the capture process and, consequently, reducing as many possible identity frauds as possible. The SDK has some blocks that may prevent its execution in certain contexts. To disable them, you can use the methods as shown in the example below:
Attention! Disabling security validations is recommended for test environments only. For publishing your application in production, we recommend using the default settings.
General customizations
DocumentDetector |
CPF of the user who is using the plugin to be used for fraud detection via analytics |
Enables/disables data collection for maximizing anti-fraud information. Default is |
Flow of documents to be captured in the SDK |
Change the setting for the inflated popups before each document. The default is |
Enables/disables sounds. The default is |
Changes the default network settings. The default is |
Preview for checking photo quality |
.setAutoDetection(bool enable) Enables/disables auto detection and sensor checks. Use |
Delay the activity after the completion of each step. This method can be used to display a success message on the screen itself after the capture, for example. Default is |
Allows you to customize messages displayed in the "status" balloon during the capture and analysis process. |
Sets the time the image URL will last on the server until it is expired. Expect to receive a time interval between "30m" to "30d". The default is |
Customizations only applied on Android |
Customizations only applied on iOS |
Define the settings for uploading documents. By enabling this option, the SDK flow will prompt the user to upload the document files instead of capturing them with the device's camera. This option also includes document quality checks. By default, this flow option is not enabled |
Allows you to choose the environment in wich the SDK will run (production or beta). The expected |
Each environment (beta and production) requires its own specific mobileToken, generated in the Trust platform of the respective environment.
|
DocumentDetectorStep constructor |
Document to be scanned in this respective step |
Visual customizations of the respective step applied on Android |
Visual customizations of the respective step applied on iOS |
UploadSettings constructor |
Enables/disables file compression before uploading. Default is |
Sets the maximum size in KB of the file to upload. The default limit is 20000 KB (20MB) |
Defines the file format(s) that will be accepted for upload. By default it accepts: .PDF , .JPG, .JPEG, .PNG, .HEIF |
Sets the background layout of the document upload |
Sets the layout of the document upload request popup |
ShowPreview |
How to Modify: If you want to modify the selected text, modify the String with the message you want to use. |
Preview Enable/Disable |
Title |
Subtitle |
Confirmation Pushbutton Text |
Retrieve Capture Button Text |
Example of use
MessageSettings |
How to Modify: If you want to modify the selected text, modify the String with the message you want to use. |
Default: "Please Wait..." |
Default: "Fit the document on the markup" |
Default: "Hold like this" |
Default: "Checking quality..." |
Default: "Ops, could not read the information. Please try again". |
Default: "Sending image..." |
Default: |
Default: "Close your document and try again" |
PadrĆ£o: "Didn't found a document" |
Default: "Area near you is too dark". |
Default: "The device is not on the horizontalā |
Default: "Keep the device stillā |
Default: "Ops, it seems that this document is not supported. Contact us!" |
Default: "Dispose the document in a desk, centralize it on the markup and hold the automatic capture." |
Pattern: "OK, understood!" |
Default: "Ops, this is the RG's Front" |
Default: "Ops, this is the RG's Back". |
Default: "Ops, this is the RG Opened" |
Default: "Ops, this is the CNH's Front" |
Default: "Ops, this is the CNH's Back" |
Default: "Ops, this is the CNH Opened" |
Default: "Ops, this is the CRLV". |
Default: "Ops, this is the RNE's Front" |
Default: "Ops, this is the RNE's Back" |
Example of use
Android
DocumentDetectorStepCustomizationAndroid constructor |
Name of the string resource to be shown in the document name label. For example, if you want to show the String "Test", create a String in |
Name of the drawable resource to be shown in the capture intro popup. For example, if you want to show a custom illustration, save it in |
Name of the raw resource to run at the start of the capture. For example, if you want to play a custom audio, save it in |
DocumentDetectorAndroidSettings constructor |
Customization of the activity's Android layout |
Customization of the capture sensor settings |
Array of stages for each capture. This parameter is useful if you want to change the way the DocumentDetector runs, such as detection settings, automatic or manual capture, checking photo quality, etc. |
Allows you to configure the quality in the compression process. By default, all captures go through compression. The method expects values between 50 and 100 as a parameter, where 100 is the best quality compression (recommended). The default is 100 |
Allows you to enable or disable the reverse camera button. The default is |
Allows you to set the capture resolution. The method takes as parameter a Resolution that provides the options HD, FULL_HD, QUAD_HD and ULTRA_HD. The default is |
Allows you to enable/disable features of the SDK that consume GoogleServices in the SDK, we do not recommend disabling the services because of the loss of security. Default is |
Allows the use of emulator when |
Allows use of root devices when |
Enables/disables the use of the app in debug mode. Default is |
CaptureStage constructor |
Duration in milliseconds of this respective step before moving on to the next, if any. |
Flag to set if this stage enable/disable sensors validations (luminosity, orientation and stability) |
Document Quality Check Settings. The only parameter of |
Document detection settings for the camera. The |
Photo capture mode. It can be |
DocumentDetectorCustomizationAndroid constructor |
Name of the style resource that defines the colors of the DocumentDetector. For example, if you want to change the colors of the SDK, create a style in |
Name of the resource layout that will replace the default DocumentDetector layout. For example, if you want to change the layout of the SDK, create a layout in |
Name of the drawable resource to replace the default green mask. If you are going to use this parameter, use a mask with the same cutting area, it is important for the detection algorithm. For example, save the mask image in |
Name of the drawable resource to replace the default red mask. If you are going to use this parameter, use a mask with the same cutting area, it is important for the detection algorithm. For example, save the mask image in |
Name of the drawable resource to replace the default white mask. If you are going to use this parameter, use a mask with the same cutting area, it is important for the detection algorithm. For example, save the mask image in |
Defines the type of mask used in the captures. There are three types: |
SensorSettingsAndroid constructor |
Settings of the luminosity sensor to be applied in all steps of the SDK |
Orientation sensor settings to be applied in all SDK steps |
Orientation sensor settings to be applied in all SDK steps |
SensorLuminositySettingsAndroid constructor |
Lower threshold between acceptable/not acceptable brightness, in lx. The default is |
SensorOrientationSettingsAndroid constructor |
Lower threshold between correct/incorrect orientation, in m/sĀ² variation from fully horizontal orientation. The default is |
SensorStabilitySettingsAndroid constructor |
How many milliseconds the mobile must stay at the correct threshold to be considered stable. The default is |
Lower threshold between stable/unstable, in m/sĀ² variation between the last two sensor collections. The default is |
iOS
DocumentDetectorIosSettings constructor |
Document acceptance threshold, in a value from 0.0 to 1.0. The default is 0.95 |
Flag indicating whether you want to verify the quality of the captured document |
Quality acceptance threshold, between 1.0 and 5.0. 1.8 is recommended for future OCR |
Visual customization of the DocumentDetector |
Custom sensor settings in iOS, null to disable |
Enables manual capture mode |
Time to enable the manual capture button |
Allows you to set the quality in the compression process. By default all captures are compressed. The method expects values between 0 and 1.0 as a parameter, 1.0 being the best quality compression (recommended).The default is 1.0 |
Allows setting the capture resolution. The method takes as parameter a |
Resolution | Description |
| Specifies appropriate capture settings for output video and audio bit rates suitable for 3G sharing |
| Specifies the appropriate capture settings for the output video and audio bitrates suitable for sharing over WiFi |
| Specifies appropriate capture settings for high-quality video and audio output |
| Specifies appropriate capture settings for high-resolution photo quality output |
| Specifies appropriate capture settings for high-resolution photo quality output |
| Specifies the appropriate capture settings for video output at 720p quality (1280 x 720 pixels) |
| Capture settings suitable for 1080p (1920 x 1080 pixels) quality video output |
| Capture settings suitable for 2160p (3840 x 2160 pixels) quality video output |
DocumentDetectorCustomizationIos constructor |
The SDK's theme color. For example, if you want to use the color black, use "#000000". |
Name of the image to replace the default green mask. Remember to add the image in |
Name of the image to replace the default white mask. Remember to add the image in |
Name of the image to replace the default red mask. Remember to add the image in |
Name of the image to replace the SDK's close button. Remember to add the image in |
Flag indicating whether to show the label of the current step |
Flag indicating whether to show the current status label |
Value that sets the size of the "close" button in the SDK |
Attribute that defines the content mode of the "close" button in the SDK. Choose from these values. |
SensorSettingsIos constructor |
Settings of the luminosity sensor to be applied in all steps of the SDK |
Orientation sensor settings to be applied in all SDK steps |
Stability sensor settings to be applied in all SDK steps |
SensorLuminositySettingsIos constructor |
Threshold between acceptable/unacceptable ambient brightness. The default is |
SensorOrientationSettingsAndroid constructor |
Threshold between correct/incorrect device orientation. Higher the value more flexible it will be. Default value is |
SensorStabilitySettingsAndroid constructor |
Time between sensor's collections. The default is |
Threshold between stable/unstable, in m/sĀ² variation between the last two sensor collections. The default is |
Collecting the result
The DocumentDetector return object is of abstract type DocumentDetectorResult
. It can be an instance of DocumentDetectorSuccess
, DocumentDetectorFailure
or DocumentDetectorClosed
.
DocumentDetectorSuccess
Field | Observation |
List of document captures | It will have the same length and order as the ** |
Document type detected by the SDK itself, useful for integration with our external OCR route. For example, if you capture | Will be null if the SDK cannot check the document type or if detection is disabled |
Identifier of this execution on our servers. If possible, save this field and send it along to our API. This way we will have more data about how the user behaved during the execution | Will be null if the user sets |
Capture
Field | Observation |
Full address of the image on the device | - |
URL of the image temporarily stored in the CAF servers | Will be null if the SDK cannot check the quality or if the quality is disabled |
Detection label of the capture. For example, if the capture refers to a | Will be null if the photo is collected at a stage where detection is disabled |
Quality of the document photo, in a value from 1.0 to 5.0 | Will be null if the photo is collected at a stage where quality checking is disabled |
DocumentDtetectorFailure
Field |
Friendly message explaining why the SDK failed |
Type of fault that shut down the SDK |
The existing fault types are:
InvalidTokenReason
: when the token entered is invalid. It should not occur in a production environment;PermissionReason
: when some mandatory permission was not granted by the user. It will only occur in a production environment if your app does not ask the user or the user manually disables it before starting;NetworkReason
: server connection failure. It will occur in production if the user's device is not connected to the Internet;ServerReason
: failure in some request to our servers;SecurityReason
: when the device is not safe to run the SDK;StorageReason
: when the device does not have enough space to capture a photo. This can happen in production;LibraryReason
: when some internal failure made it impossible to execute the SDK. It may occur due to project configuration errors, and should not occur in production;
Customizing iOS views
For iOS customization, it is necessary that the Flutter plugins are added locally to the project. The customization is done natively with the ViewCode approach.
****Click here for an example with a guide to using this feature.
Last updated