DocumentDetector v9.x or above
Current Version
Name | Version |
---|---|
| 15.0.3 |
Requirements
Deployment Info | Version |
---|---|
iOS Target | 13.0+ |
Xcode | 15.4+ |
Swift | 5.3.2+ |
A valid caf mobileToken.
Cocoapods installed or SPM
Required permissions
In the info.plist
file, add the permissions below:
Permission | Reason | Required? |
| To capture the document photo(s) | No, only required in camera capture stream |
| To perform the gallery opening. | No, required only in the upload stream |
SDK size
The SDK will add approximately 8 MB to your final app.
Installation
CocoaPods
In your Podfile, specify the reference to our framework. Replacing <version>
with the current version:
SPM
Open your Xcode project.
Navigate to File > Add Packages.
In the search bar, paste the URL of this repository:
Supported documents
Currently supported documents are:
Instantiating the SDK
First, instantiate an object of type DocumentDetectorSdk
:
We recommend paying special attention to the SDK implementation for low-end devices. For better performance and user experience, consider using the document upload flow instead of the capture mode.
Another point of attention: please note that the automatic document capture option is only available for devices with iOS 13+. Below this version, the SDK will only enable the manual document capture option.
DocumentDetector Options
Parameter | Required? |
Usage token associated with your CAF account. | Yes. |
Sets the document capture flow, as explained here. | Yes. |
Identifier of the user for the purpose of identifying a fraudulent profile. | No, only used for analytics. |
Enables/disables data collection for analytics. | No, the default is |
Change the setting of the inflated popups before each document. | No, the default is |
It allows you to change some of the SDK's layout attributes, such as buttons, colors and fonts. See the available options and an example here. | No. |
Change the default network settings. | No. The default is |
Defines threshold between acceptable/unacceptable ambient brightness. The threshold of this sensor is a number ranging from negative to positive. | No. The default setting is |
Defines threshold between correct/incorrect device orientation. Higher the value more flexible it will be. The threshold of this sensor is the acceleration of the device. | No. The default setting is |
Changes the default settings of the stability sensor. The threshold of this sensor is in the range of the last two accelerations collected from the device. | No. The default setting is |
Sets the proxy settings, as explained here. | No. The default is |
Enables/disables the capture preview. If | No. The default is |
Allows customizing messages displayed in the feedback label during the capture and analysis process.See the available attributes here. | No. |
Allows you to configure the quality in the compression process. By default, all captures go through compression. The method expects values between 0.8 and 1.0 as a parameter, where 1.0 is the best quality compression. | No. The default is |
Enables/disables manual capture. The time parameter sets the | No. For iPhone 11 devices and above by default this setting is disabled. Iphone X and below the manual capture mode is the default and the only setting available. |
Enables/disables multi-language support. | No. The default is enabled. |
Sets how long the image URL will last on the server until it is expired. Expect to receive a time interval between "30m" to "30d". Examples:
| No. The default is |
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. | No. The default is |
Sets 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 type and quality checks. See how to set it here. | No. By default this option is disabled. |
Allows you to set the capture resolution. The method takes as parameter a
| No. The default is |
Enables the option to allow passports from only a certain issuing country, or, a list of countries. See the complete list at: ISO 3166-1 alpha-3. Example:
| No. Passports issued by any country are accepted by default. |
DocumentDetectorStep
To create a capture flow, you will need to create an array of DocumentDetectorStep
, where each element will be a capture step. To construct each DocumentDetectorStep
object, you can enter the following elements:
Parameter | Required? |
Identifies which document you want to capture in the respective step. | Yes. |
Text to be displayed at the bottom of the layout. | No. There is a pattern per |
Illustration to be shown in the popup before the capture. | No. There is a pattern per |
Present the text to be displayed at the top of the layout. | No. the default is |
Customizing layout
You can customize the layout by creating an object of type DocumentDetectorLayout
and passing it as a parameter in setLayout()
. The DocumentDetectorLayout
elements are:
Parameter | Description | Required? |
| Icon of close SDK button. | No. |
| Color of close SDK button. | No. |
| Size of close SDK button. | No. |
| Content mode of close SDK button. | No. |
| Font of all SDK texts. | No. |
| Background color for the upload flow. | No. |
| Background color for the preview screen. | No. |
| Principal color, applied to buttons. | No. |
| Colors of the feedback area. All colors have an opacity of 0.4 by default. | No. |
Example
MessageSettings
Attribute | Default Value |
Message displayed when SDK is in the process of opening. | "Please Wait…" |
Message advising to fit the document to the mask. | "Fit the document on the markup" |
Message displayed when the SDK makes a request to the backend, verifying quality. | "Checking Quality…" |
Message displayed when the quality of the capture fails. | "Ops, could not read the information. Please try again" |
Message displayed when there is no quality check and the capture is being saved on the servers. | "Sending Image…" |
Text displayed in the step initialization popup. | "Dispose the document in a desk, centralize it on the markup and hold the automatic capture." |
Message displayed when a unexpected type of document is displayed for capture. | "Ops, it seems that this document is not supported. Contact us!" |
Message displayed when the document is displayed in a different stream than expected. | "Oops, this document is not the %@" |
Message displayed when the brightness threshold is lower than expected. | "Area near you is too dark" |
Message displayed when the orientation threshold is lower than expected. | "The device is not on the horizontal" |
Message displayed when the orientation threshold is lower than expected. | "Keep the device still" |
Message displayed to request a document to be present on the camera. | "Scan a document" |
Message displayed to request to get closer to the document. | "Get closer to the document" |
Message displayed to request to center the document. | "Center the document" |
Message displayed to request to move away from the document. | "Move away from the document" |
Message displayed to request to align the document. | "Align the document" |
Message displayed to request to turn document 90 degrees. | "Turn the document 90 degrees" |
Message displayed to alert that the document was captured. | "Document captured" |
CafUploadSettings
To activate the document upload functionality it is necessary to instantiate an object of type CafUploadSettings()
and set its parameters:
Parameter | Required? |
Enables/disables this feature. | No. The default is |
Enables/disables file compression before uploading. | No. The default is |
Defines the file format(s) that will be accepted for upload. | No. By default |
Sets the maximum KB limit of the file to upload. | No. The default limit is 10000 KB (10MB). |
Currently, the supported file formats are:
Getting the result
To get the result, you must implement the DocumentDetectorControllerDelegate
delegate in your controller:
After creating the DocumentDetector
object, start the DocumentDetectorController
by passing this object as a parameter in the constructor:
DocumentDetectorResult
Parameter | Can it be null? |
The array with the respective captures of the parameterized documents. | Yes, in case of error. |
type: String The class of the read document stream. This parameter is useful in an integration with our OCR route. The existing types are: | Yes, in case of error. |
trackingId: String? Identifier of this run 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. | Yes, if the user sets |
CafCapture
Parameter | Can it be null? |
Document image. | No. |
URL of the document on Caf's server. This URL has an expiry time, which can be set with the | No. |
Label of the respective document within the following possibilities: | No. |
Quality inferred by the document quality algorithm. Varies between 0 and 5. | No. |
DocumentDetectorFailure
Superclass that leads to the SDK shutdown. To find out what the reason was, find out which object class has the isKindOfClass()
method, equivalent to instanceof
in Java and is
in Dart:
isKindOfClass() | Description | Exemple |
| The token entered is not valid for the corresponding product. | Parameterize "test123" as token in the SDK builder. |
| You are missing some mandatory permission to run the SDK. | Start DocumentDetector without camera permission granted. |
| Internet connection failure. | User was without internet during facematch in FaceAuthenticator. |
| When an SDK request receives a status code of failure. | In theory, it shouldn't happen. If it does, let us know! |
Last updated