> For the complete documentation index, see [llms.txt](https://docs.caf.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.caf.io/caf-sdk/ios/standalone-modules/deprecated-sdks/document-detector-deprecated.md).

# DocumentDetector v7 or below (Deprecated)

## **Supported documents**

Currently, the documents supported on iOS are:

```swift
Document.RG_FRONT, // front of the ID, where the picture is
Document.RG_BACK, // back of the ID, where the data is
Document.RG_FULL, // open ID, showing both the front and the back
Document.CNH_FRONT, // the front of the CNH, where the picture is
Document.CNH_BACK, // the back of the CNH, where the signature is
Document.CNH_FULL, // open CNH, showing both the front and the back
Document.CRLV, // CRLV
Document.RNE_FRONT, // the front of the RNE and RNM, the part with the data
Document.RNE_BACK, // back of the RNE and RNM, the part with the picture
Document.PASSPORT, // Passport
Document.CTPS_FRONT, // front of the CTPS
Document.CTPS_BACK, // Back of the CTPS
Document.OTHERS, // other identification documents in general, such as RNE, Military ID, OAB, and CRLV
Document.ANY; // allows sending any capture
```

## **Required permissions**

In the **`info.plist`** file, add the permissions below:

| **Permission**                                  | **Reason**                       | **Required?**                              |
| ----------------------------------------------- | -------------------------------- | ------------------------------------------ |
| **`Privacy - Camera Usage Description`**        | To capture the document photo(s) | No, only required in camera capture stream |
| **`Privacy - Photo Library Usage Description`** | To perform the gallery opening.  | No, required only in the upload stream     |

NSPhotoLibraryUsageDescription

## **Utilization**

First, instantiate an object of type **`DocumentDetectorSdk`**:

```swift
let documentDetector = DocumentDetectorSdk.Builder(mobileToken: "mobileToken") // enableMultiLanguage true by default
    // see table bellow
    .build()
```

### **DocumentDetectorSdk.Builder**

| **Parameter**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | **Required?**                                                                                            |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- |
| <p><strong><code>String mobileToken</code></strong></p><p>Usage token associated with your CAF account</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | Yes                                                                                                      |
| <p><strong><code>.setDocumentDetectorFlow(flow :\[DocumentDetectorStep])</code></strong></p><p>Sets the document capture flow, as explained <a href="https://github.com/combateafraude/public-docs/blob/docs-sdks/ios/deprecated-sdks/v8-or-below.md#documentdetectorstep">here</a></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | Yes                                                                                                      |
| <p><strong><code>.setPeopleId(peopleId: String?)</code></strong></p><p>Identifier of the user for the purpose of identifying a fraudulent profile</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | No, only used for [analytics](https://github.com/combateafraude/public-docs/blob/docs-sdks/analytics.md) |
| <p><strong><code>.setAnalyticsSettings(useAnalytics: Bool)</code></strong></p><p>Enables/disables data collection for <a href="https://github.com/combateafraude/public-docs/blob/docs-sdks/analytics.md">analytics</a></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                | No, the default is **`true`**                                                                            |
| <p><strong><code>.setPopupSettings(show: Bool)</code></strong></p><p>Change the setting of the inflated popups before each document</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | No, the default is **`true`**                                                                            |
| <p><strong><code>.setDetectionSettings(detectionThreshold : Float)</code></strong></p><p>Changes the default document detection setting, the frame confidence threshold (from 0.0 to 1.0, where 1.0 indicates that the SDK will only accept the document with a perfect frame)</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         | No. The default is 0.91                                                                                  |
| <p><strong><code>.setQualitySettings(verifyQuality: Bool, qualityThreshold: Double?)</code></strong></p><p>Changes the default setting for verifying the quality of the captures, indicating whether you want to perform this verification (takes about 2 seconds) and the quality threshold for these photos can be set (value from 1.0 to 5.0). In addition, the SDK will return the URL of the image in the variable <code>DocumentDetectorResult.Capture.ImageUrl</code>. <strong>Be careful</strong>, if you decide to check the quality in this parameter and there is a connection failure while sending the images, the SDK will terminate with an internet error.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | No. The default is true and 1.8, respectively                                                            |
| <p><strong><code>.setLayout(layout: DocumentDetectorLayout)</code></strong></p><p>Changes the document masks from success, failure, and normal.</p><p>It also allows you to change the sound and cancel buttons at the top of the screen. See the <a href="https://github.com/combateafraude/public-docs/blob/docs-sdks/customization/README.md">example</a>.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | No                                                                                                       |
| <p><strong><code>.setColorTheme(color: UIColor)</code></strong></p><p>Change the color of the sound and cancel buttons that are at the top of the screen. Also change the color of the popup buttons, inflated before each document.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | No                                                                                                       |
| <p><strong><code>.enableSound(enableSound: Bool)</code></strong></p><p>Enables/disables sounds and the sound icon in the SDK</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | No, the default is **`true`**                                                                            |
| <p><strong><code>.showStepLabel(show: Bool)</code></strong></p><p>Show/hide the lower middle label (which contains the document name)</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | No, the default is **`true`**                                                                            |
| <p><strong><code>.showStatusLabel(show: Bool)</code></strong></p><p>Show/hide the central label (which contains the status)</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | No, the default is **`true`**                                                                            |
| <p><strong><code>.setNetworkSettings(requestTimeout:TimeInterval)</code></strong></p><p>Change the default network settings</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | No. The default is 60 (seconds)                                                                          |
| <p><strong><code>.setLuminositySensorSettings(luminosityThreshold :Float?)</code></strong></p><p>Defines threshold between acceptable/unacceptable ambient brightness. The threshold of this sensor is a number ranging from negative to positive.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | No. The default setting is -3.                                                                           |
| <p><strong><code>.setOrientationSensorSettings(orientationThreshold: Double?)</code></strong></p><p>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</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | No. The default setting is 0.3.                                                                          |
| <p><strong><code>.setStabilitySensorSettings(stabilityThreshold: Double?)</code></strong></p><p>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.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                            | No. The default setting is 0.3.                                                                          |
| <p><strong><code>.setProxySettings(proxySettings: ProxySettings?)</code></strong></p><p>Sets the proxy settings, as explained <a href="https://github.com/combateafraude/public-docs/blob/docs-sdks/configurations/proxy-configuration.md">here</a></p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | No. The default is **`null`**                                                                            |
| <p><strong><code>.showPreview(\_ show: Bool, title: String?, subtitle: String?, confirmLabel: String?, retryLabel: String?)</code></strong></p><p>Enables/disables the capture preview. If <strong><code>show</code></strong> has <strong><code>true</code></strong>, after each capture, the SDK provides a screen for the user to approve or make the capture again. For the remaining parameters, enter <strong><code>nil</code></strong> to use the default value or a String for a custom text.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   | No. The default is **`false`**                                                                           |
| <p><strong><code>.setMessageSettings(waitMessage: String?, fitTheDocumentMessage: String?, verifyingQualityMessage: String?, lowQualityDocumentMessage: String?, uploadingImageMessage: String?, popupDocumentSubtitleMessage: String?, unsupportedDocumentMessage: String?, wrongDocumentMessage\_RG\_FRONT: String?, wrongDocumentMessage\_RG\_BACK: String?, wrongDocumentMessage\_RG\_FULL: String?, wrongDocumentMessage\_CNH\_FRONT: String?, wrongDocumentMessage\_CNH\_BACK: String?, wrongDocumentMessage\_CNH\_FULL: String?, wrongDocumentMessage\_CRLV: String?, wrongDocumentMessage\_RNE\_FRONT: String?, wrongDocumentMessage\_RNE\_BACK: String?, sensorLuminosityMessage: String?, sensorOrientationMessage: String?, sensorStabilityMessage: String?)</code></strong></p><p>Allows customizing messages displayed in the "status" balloon during the capture and analysis process. <a href="https://github.com/combateafraude/public-docs/blob/docs-sdks/ios/deprecated-sdks/v8-or-below.md#messagesettings">example</a></p>                                                                                                                                                             | No.                                                                                                      |
| <p><strong><code>.setCompressSettings(compressionQuality: CGFloat)</code></strong></p><p>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 parameters, 1.0 being the best quality compression (recommended).</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           | No. The default is 1.0                                                                                   |
| <p><strong><code>.setManualCaptureSettings(enable: Bool, time: TimeInterval)</code></strong></p><p>Enables/disables manual capture. The time parameter sets the <strong><code>time</code></strong> for the capture mode to be enabled.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | No. The default is disabled                                                                              |
| <p><strong><code>.enableMultiLanguage(\_ enable: Bool)</code></strong></p><p>Enables/disables multi-language support.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | No. The default is enabled                                                                               |
| <p><strong><code>.setGetImageUrlExpireTime(expireTime: String)</code></strong></p><p>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".</p><p>Examples:</p><p><strong><code>setGetImageUrlExpireTime("30m")</code>:</strong> To set minutes only</p><p><strong><code>setGetImageUrlExpireTime("24h")</code>:</strong> To set only hour(s)</p><p><strong><code>setGetImageUrlExpireTime("1h 10m")</code>:</strong> To set hour(s) and minute(s)</p><p><strong><code>setGetImageUrlExpireTime("10d")</code>:</strong> To set day(s)</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      | No. The default is **`3h`**                                                                              |
| <p><strong><code>.setMask(type: MaskType)</code></strong></p><p>Sets the type of mask used in the captures. There are three types:</p><p><code>.</code><strong><code>standard</code></strong>, with the dotted pattern in the document format;</p><p><code>.</code><strong><code>empty</code></strong>, which removes the mask entirely.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               | No. The default is **`.standard`**                                                                       |
| <p><strong><code>.setCurrentStepDoneDelay(currentStepDoneDelay: TimeInterval)</code></strong></p><p>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.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    | No. The default is **`false`**                                                                           |
| <p><strong><code>.setUploadSettings(UploadSettings uploadSettings)</code></strong></p><p>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 quality checks. <a href="https://github.com/combateafraude/public-docs/blob/docs-sdks/ios/deprecated-sdks/v8-or-below.md#uploadsettings">example</a> of implementation.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                             | No. By default this option is disabled.                                                                  |
| <p><strong><code>.setResolutionSettings(resolution: Resolution)</code></strong></p><p>Allows you to set the capture resolution. The method takes a parameter a Resolution, which has the following options:</p><ul><li><code>low</code> Specifies appropriate capture settings for output video and audio bit rates suitable for 3G sharing</li><li><code>medium</code> Specifies the appropriate capture settings for the output video and audio bitrates suitable for sharing over WiFi</li><li><code>high</code> Specifies appropriate capture settings for high-quality video and audio output</li><li><code>photo</code> Specifies appropriate capture settings for high-resolution photo quality output</li><li><code>inputPriority</code> Specifies appropriate capture settings for high-resolution photo quality output</li><li><code>hd1280x720</code> Specifies the appropriate capture settings for video output at 720p quality (1280 x 720 pixels)</li><li><code>hd1920x1080</code> Capture settings suitable for 1080p (1920 x 1080 pixels) quality video output</li><li><code>hd4K3840x2160</code> Capture settings suitable for 2160p (3840 x 2160 pixels) quality video output</li></ul> | No. The default is **`hd1920x1080`**                                                                     |
| <p><strong><code>.setAllowedPassportCountriesList(passportList: \[CountryCodes])</code></strong></p><p>Enables the option to allow passports from only a certain issuing country, or, a list of countries. See the complete list at: <a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3">ISO 3166-1 alpha-3</a></p><p>Example:</p><ul><li><strong><code>.setAllowedPassportList(passportList: \[CountryCodes.BRA])</code></strong></li></ul>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | 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?**                                  |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------- |
| <p><strong>document: Document</strong></p><p>Identifies which document you want to capture in the respective step</p>                                                                                                                            | Yes                                            |
| <p><strong>stepLabel: String?</strong></p><p>Text to be displayed at the bottom of the layout</p>                                                                                                                                                | No. There is a pattern per **`Document`** Type |
| <p><strong>illustration: UIImage?</strong></p><p>Illustration to be shown in the popup before the capture</p>                                                                                                                                    | No. There is a pattern per **`Document`** Type |
| <p><strong>audio: URL?</strong></p><p>Audio to be played at the beginning of the step. <a href="https://github.com/combateafraude/public-docs/blob/docs-sdks/ios/deprecated-sdks/v8-or-below.md#how-to-get-the-url-of-an-audio">Example</a>.</p> | No. There is a pattern per **`Document`** Type |

### **MessageSettings**

| **Attribute**                                                                                                                                                                                                             | **Default Value**                                                                             |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------- |
| <p><strong><code>waitMessage: String</code></strong></p><p>Message displayed when SDK is in the process of opening.</p>                                                                                                   | "Please Wait…"                                                                                |
| <p><strong><code>fitTheDocumentMessage: String</code></strong></p><p>Message advising to fit the document to the mask.</p>                                                                                                | "Fit the document on the markup"                                                              |
| <p><strong><code>verifyingQualityMessage: String</code></strong></p><p>Message displayed when the SDK makes a request to the backend, verifying quality.</p>                                                              | "Checking Quality…"                                                                           |
| <p><strong><code>lowQualityDocumentMessage: String</code></strong></p><p>Message displayed when the quality of the capture fails.</p>                                                                                     | "Ops, could not read the information. Please try again"                                       |
| <p><strong><code>uploadingImageMessage: String</code></strong></p><p>Message displayed when there is no quality check and the capture is being saved on the servers.</p>                                                  | "Sending Image…"                                                                              |
| <p><strong><code>popupDocumentSubtitleMessage: String</code></strong></p><p>Text displayed in the step initialization popup.</p>                                                                                          | "Dispose the document in a desk, centralize it on the markup and hold the automatic capture." |
| <p><strong><code>unsupportedDocumentMessage: String</code></strong></p><p>Message displayed when a unexpected type of document is displayed for capture.</p>                                                              | "Ops, it seems that this document is not supported. Contact us!"                              |
| <p><strong><code>wrongDocumentMessage\_RG\_FRONT: String</code></strong></p><p>Message displayed when the front of the RG(Brazilian ID card) is displayed in a different flow than expected.</p>                          | "Ops, this is the RG's Front"                                                                 |
| <p><strong><code>wrongDocumentMessage\_RG\_BACK: String</code></strong></p><p>Message displayed when the RG(Brazilian ID card) version is displayed in a different flow than expected.</p>                                | "Ops, this is the RG's Back"                                                                  |
| <p><strong><code>wrongDocumentMessage\_RG\_FULL: String</code></strong></p><p>Message displayed when the open RG(Brazilian ID card) is displayed in a different stream than expected.</p>                                 | "Ops, this is the RG Opened"                                                                  |
| <p><strong><code>wrongDocumentMessage\_CNH\_FRONT: String</code></strong></p><p>Message displayed when the front of the CNH(Brazilian driver's license) is displayed in a different stream than expected.</p>             | "Ops, this is the CNH's Front"                                                                |
| <p><strong><code>wrongDocumentMessage\_CNH\_BACK: String</code></strong></p><p>Message displayed when the version of the CNH(Brazilian driver's license) is displayed in a different stream than expected.</p>            | "Ops, this is the CNH's Back"                                                                 |
| <p><strong><code>wrongDocumentMessage\_CNH\_FULL: String</code></strong></p><p>Message displayed when the open CNH(Brazilian driver's license) is displayed in a different stream than expected.</p>                      | "Ops, this is the CNH Opened"                                                                 |
| <p><strong><code>wrongDocumentMessage\_CRLV: String</code></strong></p><p>Message displayed when the CRLV(Brazilian Vehicle Registration and Licensing Certificate) is displayed in a different stream than expected.</p> | "Ops, this is the CRLV"                                                                       |
| <p><strong><code>wrongDocumentMessage\_RNE\_FRONT: String</code></strong></p><p>Message displayed when the front of the RNE(National Registry of Foreigners) is displayed in a different stream than expected.</p>        | "Ops, this is the RNE's Front"                                                                |
| <p><strong><code>wrongDocumentMessage\_RNE\_BACK: String</code></strong></p><p>Message displayed when the back of the RNE(National Registry of Foreigners) is displayed in a different stream than expected.</p>          | "Ops, this is the RNE's Back"                                                                 |
| <p><strong><code>sensorLuminosityMessage: String</code></strong></p><p>Message displayed when the brightness threshold is lower than expected.</p>                                                                        | "Area near you is too dark"                                                                   |
| <p><strong><code>sensorOrientationMessage: String</code></strong></p><p>Message displayed when the orientation threshold is lower than expected.</p>                                                                      | "The device is not on the horizontal"                                                         |
| <p><strong><code>sensorStabilityMessage: String</code></strong></p><p>Message displayed when the orientation threshold is lower than expected.</p>                                                                        | "Keep the device still"                                                                       |

### **UploadSettings**

To activate the document upload functionality it is necessary to instantiate an object of type **`UploadSettings`()** and set its parameters:

| **Parameter**                                                                                                       | **Required?**                                     |
| ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------- |
| <p><strong><code>enable</code></strong></p><p>Enables/disables this feature.</p>                                    | No. The default is **`true`**                     |
| <p><strong><code>compress</code></strong></p><p>Enables/disables file compression before uploading.</p>             | No. The default is **`true`**                     |
| <p><strong><code>fileFormats</code></strong></p><p>Defines the file format(s) that will be accepted for upload.</p> | No. By default .PDF , .JPEG and .PNG are accepted |
| <p><strong><code>maximumFileSize</code></strong></p><p>Sets the maximum KB limit of the file to upload.</p>         | No. The default limit is 10000 KB (10MB).         |

Currently, the supported file formats are:

```swift
public enum FileFormat: String {
    case png
    case jpeg
    case pdf
}
```

## **Getting the result**

To get the result, you must implement the **`DocumentDetectorControllerDelegate`** delegate in your controller:

```swift
class YouController: UIViewController, DocumentDetectorControllerDelegate{
    
    // MARK: - Document Detection Delegates
    
    func documentDetectionController(_ scanner: DocumentDetectorController, didFinishWithResults results: DocumentDetectorResult) {
        //Called when the process was successfully executed
        //The result variable contains the data obtained
    }
    
    func documentDetectionControllerDidCancel(_ scanner: DocumentDetectorController) {
        // Called when the user cancel
    }
    
    func documentDetectionController(_ scanner: DocumentDetectorController, didFailWithError error: DocumentDetectorFailure) {
        //Called when the process terminate with an error
        //The error variable contains info about error
    }
}
```

After creating the **`DocumentDetector`** object, start the **`DocumentDetectorController`** by passing this object as a parameter in the constructor:

```swift
let scannerVC = DocumentDetectorController(documentDetector: documentDetector)
scannerVC.documentDetectorDelegate = self
present(scannerVC, animated: true, completion: nil)
```

### **DocumentDetectorResult**

| **Parameter**                                                                                                                                                                                                                                                                                                       | **Can it be null?**                                                                 |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| <p><strong><code>captures:\[Capture]</code></strong></p><p>The array with the respective captures of the parameterized documents</p>                                                                                                                                                                                | Yes, in case of error                                                               |
| <p><strong>type: String</strong></p><p>The class of the read document stream. This parameter is useful in an integration with our OCR route. The existing types are: <strong><code>\["blank", "cnh", "cnh\_new", "generic", "rg", "rg\_new", "rne", "rnm", "ctps", "passport, crlv, crlv\_new"]</code></strong></p> | Yes, in case of error                                                               |
| <p><strong>trackingId: String?</strong></p><p>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</p>                                                                                 | Yes, if the user sets **`useAnalytics = false`** or the analytics calls do not work |

### **Capture**

| **Parameter**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        | **Can it be null?**                               |
| ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------- |
| <p><strong><code>image: UIImage</code></strong></p><p>Document image</p>                                                                                                                                                                                                                                                                                                                                                                                                                             | No                                                |
| <p><strong><code>imageUrl :String</code></strong></p><p>URL of the document on CAF's server. If you want this URL, keep enabled the parameter that checks the image quality</p>                                                                                                                                                                                                                                                                                                                      | Yes, if you choose not to check the image quality |
| <p><strong><code>scannedLabel :String</code></strong></p><p>Label of the respective document within the following possibilities: <strong><code>\["blank", "cnh\_back", "cnh\_front", "cnh\_full", "new\_cnh\_back", "new\_cnh\_front", "new\_cnh\_full", "crlv", "crlv\_new", "generic", "rg\_back", "rg\_front", "rg\_full", "rg\_new\_back", "rg\_new\_front", "rg\_new\_full", "rne\_back", "rne\_front", "rnm\_back", "rnm\_front", "ctps\_back", "ctps\_front", "passport"]</code></strong></p> | No                                                |
| <p><strong><code>quality :Double</code></strong></p><p>Quality inferred by the document quality algorithm, when enabled. Varies between 1.0 and 5.0</p>                                                                                                                                                                                                                                                                                                                                              | May be 0, if the SDK does not check for quality   |
| <p><strong><code>lensFacing: Int</code></strong></p><p>Defines the face of the camera that was used. Use <strong><code>DocumentDetectorResult.LENS\_FACING\_FRONT</code></strong> or <strong><code>DocumentDetectorResult.LENS\_FACING\_FRONT</code></strong> to validate.</p>                                                                                                                                                                                                                       | 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**                                                                       |
| ------------------------ | ------------------------------------------------------------ | --------------------------------------------------------------------------------- |
| **`InvalidTokenReason`** | The token entered is not valid for the corresponding product | Parameterize "test123" as token in the SDK builder                                |
| **`PermissionReason`**   | You are missing some mandatory permission to run the SDK     | Start DocumentDetector without camera permission granted                          |
| **`NetworkReason`**      | Internet connection failure                                  | User was without internet during facematch in FaceAuthenticator                   |
| **`ServerReason`**       | When an SDK request receives a status code of failure        | In theory, it shouldn't happen. If it does, let us know!                          |
| **`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 |

## **Examples**

### **Customizing the Layout**

You can customize the layout by creating an object of type **`DocumentDetectorLayout`** and passing it as a parameter in **`DocumentDetectorBuilder`**:

```swift
let layout = DocumentDetectorLayout()

layout.changeMaskImages(
    greenMask: UIImage(named: "my_green_mask"),
    whiteMask: UIImage(named: "my_white_mask"),
    redMask: UIImage(named: "my_red_mask"))

layout.changeSoundImages(soundOn: UIImage(named: "my_sound_on_image"),
                        soundOff: UIImage(named: "my_sound_off_image"))
                        
layout.closeImage = UIImage(named: "my_close_image")
layout.buttonSize = CGFloat(50)
layout.buttonContentMode = .scaleAspectFill

layout.setFont = UIImage(named: "my_font")

let documentDetectorConfiguration = DocumentDetectorBuilder(apiToken: "API_TOKEN")
    .setDocumentDetectorFlow(flow: DocumentDetectorBuilder.RG_FLOW)
    .setLayout(layout: layout)
    .build()
```

### **How to get the URL of an audio**

```swift
let bundle = Bundle.init(for: type(of: self))
let audioURL = URL(fileURLWithPath: bundle.path(forResource: "my_audio_file", ofType: "mp3")!)
```


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.caf.io/caf-sdk/ios/standalone-modules/deprecated-sdks/document-detector-deprecated.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
