DocumentDetector v6.x and below

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

Settings

Android

In the file ROOT_PROJECT/android/app/build.gradle, add:

android {

...

    dataBinding.enabled = true
    
    compileOptions {
        sourceCompatibility = JavaVersion.VERSION_1_8
        targetCompatibility = JavaVersion.VERSION_1_8
    }
    aaptOptions {
        noCompress "tflite"
    }
}
// To perform layout customization from the SDK import the following libraries
dependencies {
    implementation "androidx.camera:camera-view:1.2.0-alpha02"
    implementation 'com.combateafraude.sdk:document-detector:7.2.5'
    // Native Android SDK that the plugin implements
    
// design libraries you will use in your layout (these are used in our example template for customization)
    implementation 'com.google.android.material:material:1.2.1'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
}

iOS

In the ROOT_PROJECT/ios/Podfile, add to the end of the file:

source 'https://github.com/combateafraude/iOS.git'
source 'https://cdn.cocoapods.org/' # or 'https://github.com/CocoaPods/Specs' if the CDN is down

Finally, add the permissions to the file ROOT_PROJECT/ios/Runner/Info.plist:

<key>NSCameraUsageDescription</key>
<string>To read the documents</string>

// Required only for the document upload flow
<key>NSPhotoLibraryUsageDescription</key>
    <string>To select images</string>

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:

dependencies:
    document_detector:
        git:
            url: https://github.com/combateafraude/Flutter.git
            ref: document-detector-v6.2.6

Runtime Permissions

Utilization

DocumentDetector documentDetector = new DocumentDetector(mobileToken: mobileToken);
documentDetector.setDocumentFlow(List<DocumentDetectorStep> documentSteps);

// Other customization parameters

DocumentDetectorResult documentDetectorResult = await documentDetector.start();

if (documentDetectorResult is DocumentDetectorSuccess) {
    // The SDK was closed successfully and the pictures of the documents were captured
} else if (documentDetectorResult is DocumentDetectorFailure) {
    // The SDK was closed due to some glitch and the document pictures were not captured
} else {
    // The user simply closed the SDK, with no result
}

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:

DocumentDetectorAndroidSettings androidSettings =
    DocumentDetectorAndroidSettings(
        emulatorSettings: true,
        rootSettings: true,
        useDeveloperMode: true,
        useAdb: true,
        useDebug: true,
    );
    
documentDetector.setAndroidSettings(androidSettings);

Attention! Disabling security validations is recommended for test environments only. For publishing your application in production, we recommend using the default settings.

General customizations

Each environment (beta and production) requires its own specific mobileToken, generated in the Trust platform of the respective environment.

|

Example of use

ShowPreview showPreview = new ShowPreview(
    show: true,
    title: "Was the photo okay?",
    subtitle: "See if the photo is sharp",
    confirmLabel: "Yes, it was good!",
    retryLabel: "Take out again");
    
documentDetector.setShowPreview(showPreview);

Example of use

MessageSettings messageSettings = new MessageSettings(
    fitTheDocumentMessageResIdName: "Example message",
    holdItMessageResIdName: "Example message",
    verifyingQualityMessageResIdName: "Example message"
    lowQualityDocumentMessageResIdName:"Example message" ,
    uploadingImageMessageResIdName:"Example message",
    openDocumentWrongMessage: "Example message",
    showOpenDocumentMessage: true);
    
documentDetector.setMessageSettings(messageSettings);

Android

iOS

Collecting the result

The DocumentDetector return object is of abstract type DocumentDetectorResult. It can be an instance of DocumentDetectorSuccess, DocumentDetectorFailure or DocumentDetectorClosed.

DocumentDetectorSuccess

Capture

DocumentDtetectorFailure

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

Logo

2023 © Caf. - All rights reserved