# On-Device Age Estimation

With an On-Device Age Estimation configuration, age estimation will run entirely on the user’s device during Face Capture. No selfie image, video, or any PII leaves the device. Only structured analysis results (for example: liveness, face quality, and the estimated age) are submitted to Incode.

Because the biometric capture never leaves the device, the feature also skips the normal selfie image upload, video/frame recording upload, and manual capture. Age decisioning is performed on the backend from the submitted results.

## **Prerequisites**

- Incode Welcome iOS SDK **5.43.0 or later**, `-l`**&#x20;(Login) variant** included. If you have not already done so, follow the steps to [install and set up](https://developer.incode.com/docs/sdk_installation_setup) the SDK.
- [**End-to-end encryption (E2EE)**](https://developer.incode.com/docs/user_guide_e2ee) enabled for your organization, plus your E2EE URL.
- A [**flow**](https://developer.incode.com/docs/using-flows) created in Dashboard. You will need its [**Flow ID**](https://developer.incode.com/docs/using-flows#other-flow-actions) - this is the `configurationID` on the session.

<Callout icon="⚠️" theme="warn">
  ### Important

  If a requirement is not met (wrong SDK variant, E2EE not active, or similar), the selfie module fails with a `notInitialized` error.
</Callout>

## **Dashboard configuration**

For server-driven flows, enable **On-Device Processing** on the Face Capture module in your Flow or Workflow configuration in Dashboard:

1. In the left menu, click **Flow Builder** > **Flows** OR **Workflows**.
2. Open your Flow or Workflow.&#x20;
3. Open the configuration panel for the Face Capture module.
4. Enable **On-Device Processing**. This ensures that liveness and age estimation run entirely on the user's device. No biometric images leave the SDK.
5. If using Workflows, click **Save configurations**. Flow configurations save automatically.
6. If using Workflows, click **Save & Publish**. If using Flows, clic&#x6B;**&#x20;Save Changes**.

The SDK reads this setting from the flow automatically. There is no code flag to set.

## **Integration steps**

### **1. Initialize the SDK**

Initialize with your API URL, E2EE URL, and API key (e.g. in AppDelegate):

```swift
import IncdOnboarding

IncdOnboardingManager.shared.initIncdOnboarding(
    url: "<YOUR_API_URL>",
    e2eeURL: "<YOUR_E2EE_URL>",
    apiKey: "<YOUR_API_KEY>"
)
```

### **2. Create the session configuration**

Use your Flow or Workflow ID and enable E2EE:

```swift
let sessionConfig = IncdOnboardingSessionConfiguration(
    configurationId: "<YOUR_FLOW_ID>",
    e2eEncryptionEnabled: true
)
```

### **3.&#x20;**&#x53;et presenting `ViewController` and start the flow

```swift
IncdOnboardingManager.shared.presentingViewController = self
IncdOnboardingManager.shared.startFlow(
    sessionConfig: sessionConfig,
    delegate: self
)
```

### **4. Handle the result in your delegate**

```swift
extension MyViewController: IncdOnboardingDelegate {
    func onSelfieScanCompleted(_ result: SelfieScanResult) {
        if let error = result.error {
            // Capture failed or was cancelled
        }
        // Results are sent to Incode backend
        // and they are not returned to the app.
    }
}
```

<Callout icon="📘" theme="info">
  ### Note

  Since images never leave the device, `SelfieScanResult` does not contain a selfie image.
</Callout>

<br />
