> ## Documentation Index
> Fetch the complete documentation index at: https://idto.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# iOS SDK

> Run the idto verification flow in a native iOS app from UIKit or SwiftUI.

The iOS SDK presents the idto verification flow modally and returns a typed result. Use `IDto.present` from UIKit with `async`/`await`, or `IDtoVerificationView` from SwiftUI.

![Aadhaar verification method choice screen](https://idto-sdk-usage-demo-bucket.s3.ap-south-1.amazonaws.com/docs/v1/img/sdk-aadhaar-method.png)

The Aadhaar step lets the user choose how to verify.

## Requirements

| Item | Value |
| - | - |
| iOS | 15.0 or later |
| Xcode | 16 or later (Swift 6 tools) |
| Device | A real device for document and selfie capture. The Simulator has no camera. |

You also need a `client_id` and `client_secret` (kept on your server), a `workflowTemplateId`, and a backend route that mints a client token. See [Authentication](https://idto.mintlify.site/authentication.md).

## Install

The package is distributed through Swift Package Manager from a private repository. Ask [tech@idto.ai](mailto:tech@idto.ai) for access. Then, in Xcode, choose **File, Add Package Dependencies** and enter:

```text theme={null}
https://github.com/idto-ai/idto-swift-sdk.git
```

Pin **Up to Next Major** from `0.1.0` and add the `IDto` library to your app target. In a `Package.swift`, add the package:

```swift theme={null}
.package(url: "https://github.com/idto-ai/idto-swift-sdk.git", from: "0.1.0")
```

Then list `.product(name: "IDto", package: "idto-swift-sdk")` in your target's dependencies.

`import IDto` gives you the whole public API.

## Permissions

Add both keys to your app's `Info.plist`. The SDK refuses to start without them.

```xml theme={null}
<key>NSCameraUsageDescription</key>
<string>We use the camera to capture your identity documents and selfie.</string>
<key>NSMicrophoneUsageDescription</key>
<string>We use the microphone during the liveness check.</string>
```

If a key is missing, `IDto.present` throws `IDtoError.missingUsageDescription(key:)`, and `IDtoVerificationView` calls `onError` with `error == "missing_usage_description"`. The SDK asks for camera access before the flow needs it. If the user declines, the flow shows its own guidance screen.

## Quick start (UIKit)

**1. Mint a client token on your server**

Your server calls `POST /auth/sdk/token` with `client_id` and `client_secret` and returns only `access_token` to the app. Recipes: [Node](https://idto.mintlify.site/recipes/sdk-token-node-express.md), [Python](https://idto.mintlify.site/recipes/sdk-token-python-fastapi.md), [Go](https://idto.mintlify.site/recipes/sdk-token-go-gin.md).

**2. Present the flow**

```swift theme={null}
import IDto

func startVerification(from presenter: UIViewController) {
    Task {
        let config = IDtoConfig(
            clientToken: try await fetchClientToken(),
            workflowTemplateId: "your-workflow-template-uuid",
            businessName: "Sample Traders",
            env: .production
        )
        do {
            let result = try await IDto.present(
                from: presenter,
                config: config,
                onStepComplete: { step in print("step", step.step) },
                onError: { err in print("error", err.step, err.error) }
            )
            if result.status == .completed, let done = result.completed {
                confirmOnServer(done.sessionToken)
            }
        } catch {
            print("not started", error)
        }
    }
}
```

`IDto.present` throws only before the flow starts: `IDtoError.sessionAlreadyActive` when a flow is already open, or `missingUsageDescription`. Afterwards it returns an `IDtoResult` whose `status` is `.completed`, `.closed`, `.abandoned` or `.error`, with `completed` or `error` filled in.

**3. Confirm the result on your server**

Callbacks drive your UI only. Confirm the session from your server with the [session result recipe](https://idto.mintlify.site/recipes/confirm-session-result.md) or a signed [webhook](https://idto.mintlify.site/concepts/webhooks.md) before you grant access.

## Quick start (SwiftUI)

`IDtoVerificationView` is driven by a `Binding<Bool>`. Set it to `true` to open the flow; the SDK sets it back to `false` when the flow ends.

```swift theme={null}
import SwiftUI
import IDto

struct ContentView: View {
    @State private var verifying = false
    let token: String

    var body: some View {
        Button("Verify your identity") { verifying = true }
            .background(
                IDtoVerificationView(
                    isPresented: $verifying,
                    config: IDtoConfig(
                        clientToken: token,
                        workflowTemplateId: "your-workflow-template-uuid"
                    ),
                    onWorkflowComplete: { done in confirmOnServer(done.sessionToken) },
                    onError: { err in print(err.error) }
                )
            )
    }
}
```

![PAN verification result screen](https://idto-sdk-usage-demo-bucket.s3.ap-south-1.amazonaws.com/docs/v1/img/sdk-pan-result.png)

A PAN result returned by the flow.

## Configuration

`IDtoConfig(clientToken:workflowTemplateId:)` is required. Every other parameter is optional.

| Parameter | Type | Purpose |
| - | - | - |
| `sessionToken` | `String?` | Resume an earlier session. |
| `startFresh` | `Bool?` | Start a new session even if one is in progress. |
| `merchantUserId` | `String?` | Your own id for this user. |
| `phone` | `String?` | Prefills the mobile number step. |
| `preVerified` | `[String: Bool]?` | Module slugs you already verified, which the flow skips. |
| `skippable` | `[String]?` | Module slugs the user may skip. See [Modules](https://idto.mintlify.site/sdks/modules.md). |
| `accumulatedData` | `[String: JSONValue]?` | Data you already hold, passed into the session. |
| `referenceName` | `String?` | Name every document name is matched against. |
| `nameMatchConfig` | `IDtoNameMatchConfig?` | `threshold`, `decisionMode` (`.all` or `.any`), `extraHonorifics`, `aliases`, `comparePairs`. |
| `faceMatchReferenceImage` | `String?` | Reference photo for face match. |
| `faceMatchConfig` | `IDtoFaceMatchConfig?` | `skipLiveness`, `threshold`, `livenessFailurePolicy` (`.failOpen`, `.failClosed`, `.needsReview`). |
| `aadhaarConfig` | `IDtoAadhaarConfig?` | `digilockerMaxFailures`, `okycEnabled`. |
| `panConfig` | `IDtoPanConfig?` | `skipContextScreen`. |
| `businessName` | `String?` | Your name in the flow header. |
| `logo` | `String?` | URL of your logo. |
| `language` | `IDtoLanguage` | `.en` (default) or `.hi`. |
| `theme` | `IDtoTheme` | `.light` (default) or `.dark`. |
| `displayMode` | `IDtoDisplayMode` | `.fullScreen` (default) or `.bottomSheet`. |
| `bottomSheet` | `IDtoBottomSheet?` | Sheet height limits. |
| `desktopModal` | `IDtoDesktopModal?` | Modal size on wide screens. |
| `env` | `IDtoEnv` | `.production` (default, `https://prod.idto.ai`) or `.development` (staging, `https://dev.idto.ai`). |
| `baseUrl` | `String?` | Overrides the API host. |
| `colors` | `IDtoColors?` | Colour overrides. |
| `getToken` | `(() async throws -> String)?` | Returns a fresh client token when the current one expires. |
| `readyTimeout` | `Double` | Milliseconds to wait for the flow to load. Default 30000. |
| `allowedHosts` | `[String]` | Extra hostnames the flow may navigate to. |
| `debug` | `Bool` | Prints the flow's log messages. Default `false`. |

## Callbacks

| Callback | Payload fields |
| - | - |
| `onStepComplete(IDtoStepData)` | `step`, `result`, `accumulatedData`, `sessionToken`, `creditsDeducted`, `balanceRemaining` |
| `onWorkflowComplete(IDtoWorkflowCompleteData)` | `allSteps`, `accumulatedData`, `sessionToken` |
| `onError(IDtoErrorData)` | `step`, `error`, `sessionToken` |
| `onAbandon(IDtoAbandonData)` | `atStep`, `reason`, `sessionToken` |

Every payload also carries `raw`, the original dictionary. `error` values other than the ones named on this page are readable messages to log, not to match on.

## See it run

<video controls width="100%" src="https://idto-sdk-usage-demo-bucket.s3.ap-south-1.amazonaws.com/docs/v1/video/flow-aadhaar-okyc.mp4" poster="https://idto-sdk-usage-demo-bucket.s3.ap-south-1.amazonaws.com/docs/v1/video/flow-aadhaar-okyc.jpg" />

Was this page helpful? Email us at [tech@idto.ai](mailto:tech@idto.ai?subject=Docs%20feedback%3A%20iOS%20SDK) with the page link.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.