> 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/passivefaceliveness.md).

# PassiveFaceLiveness (Deprecated)

## **Required permissions**

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

| **Permission**                           | **Reason**                 | **Required?** |
| ---------------------------------------- | -------------------------- | ------------- |
| **`Privacy - Camera Usage Description`** | To capture the user selfie | Yes           |

## **Utilization**

First, instantiate an object of type \*\* `PassiveFaceLiveness`:\*\*

```swift
let passiveFaceLiveness = PassiveFaceLiveness.Builder(mobileToken: "mobileToken")
    // see the table below
    .build()
```

### **PassiveFaceLiveness.Builder**

| **Parameter**                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          | **Required?**                                                                                                                                                                                                 |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <p><strong><code>String mobileToken</code></strong></p><p>Usage token associated with your CAF account</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>.setStabilitySensorSettings(message: String?, 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 is "Keep the phone still" and 1.5, respectively                                                                                                                                               |
| <p><strong><code>.setCaptureSettings( beforePictureInterval: TimeInterval?)</code></strong></p><p>Changes the settings used for capturing the selfie. The parameter indicates the time in milliseconds between the correct face fitting and the actual capture of the picture.</p>                                                                                                                                                                                                                                                                                                                                                     | No. The standard is 2.0                                                                                                                                                                                       |
| <p><strong><code>setLayout(layout: PassiveFaceLivenessLayout)</code></strong></p><p>Changes the document masks for success, failure and normal.</p><p>Also allows you to change the sound and cancel buttons at the top of the screen</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>.setProxySettings(proxySettings: ProxySettings?)</code></strong></p><p>Sets the proxy settings, as explained <a href="https://github.com/combateafraude/public-docs/blob/docs-sdks/ios/configurations/proxy-configuration.md">here</a></p>                                                                                                                                                                                                                                                                                                                                                                            | No. The default is **`nil`**                                                                                                                                                                                  |
| <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 <code>nil</code> to use the default value or a String for a custom text.</p>                                                                                                                                                | No. The default is **`false`**                                                                                                                                                                                |
| <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>.setMessageSettings(waitMessage: String?, stepName: String?, faceNotFoundMessage: String?, faceTooFarMessage: String?, faceNotFittedMessage: String?, holdItMessage: String?, invalidFaceMessage: String?, multipleFaceDetectedMessage: String?, sensorStabilityMessage: String?, verifyingLivenessMessage: String?, eyesClosedMessage: String?)</code></strong></p><p>Allows to customize messages displayed in the "status" balloon during the capture and analysis process.</p>                                                                                                                                    | No. The pattern is [this](#messagesettings)                                                                                                                                                                   |
| <p><strong><code>.setPersonCPF(personCPF: String)</code></strong></p><p>Binds a proof-of-life attempt to a cpf</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     | No. The default is **`nil`**                                                                                                                                                                                  |
| <p><strong><code>.setPersonName(personName: String)</code></strong></p><p>Binds a proof-of-life attempt to a name</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                  | No. The default is **`nil`**                                                                                                                                                                                  |
| <p><strong><code>.setManualCaptureSettings(enable: Bool, time: TimeInterval)</code></strong></p><p>Enables/disables manual capture. The <strong><code>time</code></strong> parameter sets the time for the capture mode to be enabled.</p>                                                                                                                                                                                                                                                                                                                                                                                             | No. The default is disabled                                                                                                                                                                                   |
| <p><strong><code>.enableMultiLanguage(\_ enable: Bool)</code></strong></p><p>Enable/disable multi-language support</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 | No. The default is enable                                                                                                                                                                                     |
| <p><strong><code>.setVideoCaptureSettings(time: TimeInterval)</code></strong></p><p>Allows you to enable and configure video capture.</p>                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              | No. The default is disabled                                                                                                                                                                                   |
| <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><ul><li><strong><code>setGetImageUrlExpireTime("30m")</code></strong>: To set minutes only</li><li><strong><code>setGetImageUrlExpireTime("24h")</code></strong>: To set only hour(s)</li><li><strong><code>setGetImageUrlExpireTime("1h 10m")</code>:</strong> To set hour(s) and minute(s)</li><li><strong><code>setGetImageUrlExpireTime("10d")</code>:</strong> To set day(s)</li></ul> | No. The default is **`3h`**                                                                                                                                                                                   |
| <p><strong><code>.setImageCaptureSettings(beforePictureInterval: TimeInterval!, enableManualCapture: Bool, timeManualCapture: TimeInterval)</code></strong></p><p>Allows you to set the capture per image. The beforePictureInterval attribute sets the time the user should stay with the face docked in the mask. The <strong><code>enableManualCapture</code></strong> attribute enables or disables manual capture. And <strong><code>timeManualCapture</code></strong> defines the time at which manual capture will be enabled.</p>                                                                                              | No. The default is enabled. For **`beforePictureInterval`** the default is 2 (seconds). For **`enableManualCapture`** the default is **`false`** and for **`timeManualCapture`** the default is 20 (seconds). |
| <p><strong><code>.setMask(type: MaskType)</code></strong></p><p>Sets the type of mask used in the captures. There are three types:</p><ul><li><strong><code>.standard</code></strong>, with the dotted pattern in the document format;</li><li><code>.</code><strong><code>empty</code></strong>, which removes the mask entirely.</li></ul>                                                                                                                                                                                                                                                                                           | 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>.setEyesClosedSettings(threshold: Double, isEnable: Bool)</code></strong></p><p>Allows you to customize the SDK's open-eye validation settings. The method takes as parameter <strong><code>isEnable</code></strong> to enable or disable the validation, and <strong><code>threshold</code></strong>, value between 0.0 and 1.0</p>                                                                                                                                                                                                                                                                                  | No. The default is **`true`** and **`0.5`**                                                                                                                                                                   |
| <p><strong><code>.setResolutionSettings(resolution: Resolution)</code></strong></p><p>Allows you to set the capture resolution. The method takes as parameter a <strong><code>Resolution</code></strong>, which has the following options:</p>                                                                                                                                                                                                                                                                                                                                                                                         | No. The default is **`hd1280x720`**                                                                                                                                                                           |

| **Resolution**                                                                                                                                                                                                                                                  | **Description**                                                                                                   |
| --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- |
| **`low`**                                                                                                                                                                                                                                                       | Specifies appropriate capture settings for output video and audio bit rates suitable for 3G sharing               |
| **`medium`**                                                                                                                                                                                                                                                    | Specifies the appropriate capture settings for the output video and audio bitrates suitable for sharing over WiFi |
| **`high`**                                                                                                                                                                                                                                                      | Specifies appropriate capture settings for high-quality video and audio output                                    |
| **`photo`**                                                                                                                                                                                                                                                     | Specifies appropriate capture settings for high-resolution photo quality output                                   |
| **`inputPriority`**                                                                                                                                                                                                                                             | Specifies appropriate capture settings for high-resolution photo quality output                                   |
| **`hd1280x720`**                                                                                                                                                                                                                                                | Specifies the appropriate capture settings for video output at 720p quality (1280 x 720 pixels)                   |
| **`hd1920x1080`**                                                                                                                                                                                                                                               | Capture settings suitable for 1080p (1920 x 1080 pixels) quality video output                                     |
| **`hd4K3840x2160`**                                                                                                                                                                                                                                             | Capture settings suitable for 2160p (3840 x 2160 pixels) quality video output                                     |
|                                                                                                                                                                                                                                                                 |                                                                                                                   |
| <p><strong><code>.setStage(stage: CAFStage)</code></strong></p><p>Allows you to choose the environment in wich the SDK will run (production, beta). The method takes as parameter an enum <strong><code>CAFStage</code></strong> to select the environment:</p> | No. The default is **`.PROD`**                                                                                    |
| **Enum**                                                                                                                                                                                                                                                        | **Description**                                                                                                   |
| **`.PROD`**                                                                                                                                                                                                                                                     | Will use the Trust Platform **production** environment to register the SDK executions.                            |
| **`.BETA`**                                                                                                                                                                                                                                                     | Will use the Trust Platform **beta** environment to register the SDK executions.                                  |

{% hint style="warning" %}
Each environment (beta and production) requires its own specific mobileToken, generated in the Trust platform of the respective environment.
{% endhint %}

### **MessageSettings**

| **Attribute**                                                                                                                                                     | **Default Value**                                                    |
| ----------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------- |
| <p><strong><code>waitMessage: String</code></strong></p><p>Message displayed when SDK is in the process of opening</p>                                            | "Aguarde..."                                                         |
| <p><strong><code>stepName: String</code></strong></p><p>Static label present at the bottom of the activity</p>                                                    | "Registro facial"                                                    |
| <p><strong><code>faceNotFoundMessage: String</code></strong></p><p>Message displayed when the algorithm does not recognize a face</p>                             | "Não encontramos nenhum rosto"                                       |
| <p><strong><code>faceNotFittedMessage: String</code></strong></p><p>Message displayed when the face is not fitted correctly to the mask</p>                       | "Encaixe seu rosto"                                                  |
| <p><strong><code>faceTooFarMessage: String</code></strong></p><p>Message displayed when there is a very small face</p>                                            | "Aproxime o rosto"                                                   |
| <p><strong><code>multipleFaceDetectedMessage: String</code></strong></p><p>Message displayed when more than one face is detected</p>                              | "Mais de um rosto detectado"                                         |
| <p><strong><code>holdItMessage: String</code></strong></p><p>Message displayed when the user is in the correct position for capture</p>                           | "Segure assim"                                                       |
| <p><strong><code>invalidFaceMessage: String</code></strong></p><p>Message displayed when proof-of-life verification rejects the selfie</p>                        | "Não conseguimos capturar seu rosto. Tente novamente."               |
| <p><strong><code>verifyingLivenessMessage: String</code></strong></p><p>Message displayed during proof-of-life verification.</p>                                  | "Verificando selfie…"                                                |
| <p><strong><code>captureProcessingErrorMessage: String</code></strong></p><p>Message displayed when a processing problem or error occurs in the API response.</p> | "Ops, tivemos um problema ao processar sua imagem. Tente novamente." |
| <p><strong><code>eyesClosedMessage: String</code></strong></p><p>Message displayed when both eyes are closed.</p>                                                 | "Não use óculos escuros e mantenha os olhos abertos."                |

After creating an object of type **`PassiveFaceLiveness`**, start the **`PassiveFaceLivenessController`** by passing this object as a parameter in the constructor:

```swift
let passiveVC = PassiveFaceLivenessController(passiveFaceLiveness: passiveFaceLiveness)
passiveVC.passiveFaceLivenessDelegate = self
present(passiveVC, animated: true, completion: nil)
```

## **Getting the result**

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

```swift
class YouController: UIViewController, PassiveFaceLivenessControllerDelegate{
    
    // MARK: - Passive Faceliveness Delegates
    
    func passiveFaceLivenessController(_ passiveFacelivenessController: PassiveFaceLivenessController, didFinishWithResults results: PassiveFaceLivenessResult) {
        //Called when the process was successfully executed
        //The result variable contains the data obtained
    }
    
    func passiveFaceLivenessControllerDidCancel(_ passiveFacelivenessController: PassiveFaceLivenessController) {
        //Called when the process was canceled by the user
    }
    
    func passiveFaceLivenessController(_ passiveFacelivenessController: PassiveFaceLivenessController, didFailWithError error: PassiveFaceLivenessFailure) {
        //Called when the process terminate with an error
        //The error variable contains info about error
    }
}
```

### **PassiveFaceLivenessResult**

| **Parameter**                                                                                                                                                                                                                                                                                                                                                                                                                          | **Can it be null?**                                                                 |
| -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------- |
| <p><strong><code>image: UIImage?</code></strong></p><p>Selfie picture taken or image of the best frame taken from the video - if VideoCapture format enabled.</p>                                                                                                                                                                                                                                                                      | Yes, in case of error                                                               |
| <p><strong><code>capturePath: String?</code></strong></p><p>Path of the video on the device</p>                                                                                                                                                                                                                                                                                                                                        | Yes, in case of error                                                               |
| <p><strong><code>imageUrl: String</code></strong></p><p>Url containing the jpeg selfie on our temporary server</p>                                                                                                                                                                                                                                                                                                                     | Yes, in case of error                                                               |
| <p><strong><code>signedResponse: String</code></strong></p><p>Signed response from the CAF server that confirmed that the captured selfie has a real face (it is not a snapshot or video). Use this parameter if you want an extra layer of security by checking that the signature of the response is not broken, caused by an interception of the request. If it is broken, there is a strong indication of request interception</p> | Yes, in case of error or server unavailability                                      |
| <p><strong><code>trackingId: String?</code></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 |
| <p><strong><code>lensFacing: Int</code></strong></p><p>Defines the face of the camera that was used. Use <strong><code>PassiveFaceLivenessResult.LENS\_FACING\_FRONT</code></strong> or <strong><code>PassiveFaceLivenessResult.LENS\_FACING\_FRONT</code></strong> to validate.</p>                                                                                                                                                   | No                                                                                  |

### **PassiveFaceLivenessFailure**

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 **`PassiveFaceLivenessLayout`** and passing it as a parameter to **`PassiveFaceLivenessBuilder`**:

```swift
let layout = PassiveFaceLivenessLayout()

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.setFont = UIImage(named: "my_font")

let passiveFacelivenessConfiguration = PassiveFaceLivenessBuilder(apiToken: "API_TOKEN")
    .setLayout(layout: layout)
    .build()
```


---

# 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/passivefaceliveness.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.
