> For the complete documentation index, see [llms.txt](https://docs.vida.id/identity-stack/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.vida.id/identity-stack/verify/kyc-mobile-sdk/integration-overview/ios-sdk/integration.md).

# Integration

### Import VIDA KYC

Import the VIDAKYC framework in your view controller or wherever you need to use it and acts as the entry point for all operations.

```kotlin
import vidaKYC
```

### Create VIDA KYC Instance

The VIDAKYC instance serves as the entry point for all KYC operations — initialization, starting and stopping the verification process, and releasing resources.

```kotlin
let vidaKYC = VIDAKYC()
```

### Initialize VIDA KYC&#x20;

```kotlin
vidaKYC.initialize(
    kycConfig: kycConfig,
    presentNavigationController: navigationController,
    languageCode: "en" // Optional: ISO 639-1 language code
)
```

This method prepares the SDK for the KYC flow by:

* Verifying SDK configuration and network readiness
* Establishing internal resources such as camera and backend connections
* Triggering the onInitialized() callback once the setup is complete

Important: You must call this method before any other KYC operation. If initialization fails, the SDK notifies the host application through the onError() callback.

### Start KYC Detection

```kotlin
vidaKYC.startFlow()
```

The startFlow() method begins the KYC capture and verification flow, launching the SDK camera interface and guiding users through:

* Document scanning (e.g., KTP, MyKAD, Passport, or other ID types)
* Face capture and matching (if required by the selected flow)

It handles frame processing, OCR extraction, liveness checks, and backend verification automatically. When the flow completes successfully, the SDK invokes onSuccess(response:) on the delegate.

### Stop KYC Detection

```kotlin
vidaKYC.stopFlow()
```

This method allows the host app to manually stop the KYC process before it finishes, typically in cases where:

* The user cancels the process
* An external condition (like network loss) requires halting detection

The SDK gracefully stops all camera operations and releases partial resources.<br>

### Release Resources

```kotlin
vidaKYC.releaseSDK()
```

Releasing resources is essential after completing or canceling the flow. It ensures all camera sessions, background threads, and temporary memory allocations used by the SDK are properly disposed of.

Best Practice: Always invoke releaseSDK() in your view controller's cleanup methods or after a completed session to prevent memory leaks or background processing issues.

### VIDAKYCDelegate Implementation

```kotlin
public protocol VIDAKYCDelegate: AnyObject 
    /// Called on successful completion of kyc flow.
    func onSuccess(response: VIDAKYCResponse)
    
    /// Called when an error occurs during the kyc flow.
    func onError(errorCode: Int, errorMessage: String, response: VIDAKYCResponse)
    
    /// Called when VIDAKYC is initialized successfully.
    func onInitialized()
}
```

The VIDAKYCDelegate protocol enables the host application to respond to SDK lifecycle events:

* **onInitialized()**

Called when the SDK is successfully initialized and ready to start KYC operations. You should only call startFlow() after this callback.

* **onSuccess(response: VIDAKYCResponse)**

Triggered upon successful completion of the KYC flow. The VIDAKYCResponse contains results of all backend and OCR verifications, including scores and metadata.

* **onError(errorCode: Int, errorMessage: String, response: VIDAKYCResponse)**

Called when an error occurs during initialization or the KYC process. The response object may include diagnostic data if available.

### VIDAKYCConfig

The VIDAKYCConfig class defines the configuration and authentication parameters for the KYC process.

```kotlin
let config = VIDAKYCConfig(
    token: "YOUR_ACCESS_TOKEN",
    keys: keys, //VIDAKYCKeys for configuring liveness and fraud
    livenessConfig: livenessConfig, // Optional: VIDALivenessConfig instance
    flow: .idVerification,
    delegate: self,
    errorConfiguration: errorConfig,
    uiConfiguration: uiConfig,
    viewFactory: viewFactory, // Optional: VIDAKYCViewFactory instance for custom tutorial page injections
    defaultDocumentType: .KTP,
    sdkRegion: .indonesia,
    passportCountryCode: "IDN", // Optional, for passport scanning
    enableDocAutoCapture: true,
    captureAdditionalImageWithFlash: true,     
    docAutoCaptureMinimumStableFrames: 5,
    docCaptureTimeout: 60.0,
    autoCapturePauseTimeout: 20,
    luminanceThreshold: 0.23
)
```

**Parameters**

| Parameter                         | Type                | Description                                                                                      |
| --------------------------------- | ------------------- | ------------------------------------------------------------------------------------------------ |
| token                             | String              | Token to be used for authentication                                                              |
| keys                              | VIDAKYCKeys         | Contains required keys for configuring liveness AND/OR fraudshield within sdk                    |
| livenessConfig                    | VIDALivenessConfig? | Configuration for liveness SDK (optional, required for liveness flows)                           |
| flow                              | VIDAKYCFlow         | Flow type: .kyc, or .idVerification                                                              |
| delegate                          | VIDAKYCDelegate     | Delegate for callbacks                                                                           |
| errorConfiguration                | VIDAKYCErrorConfig  | Error page configuration                                                                         |
| uiConfiguration                   | VIDAKYCUIConfig     | UI customization configuration                                                                   |
| viewFactory                       | VIDAKYCViewFactory  | A factory protocol to inject custom tutorial screens in SDK                                      |
| defaultDocumentType               | VIDAKYCDocumentType | Default document type if selection is disabled                                                   |
| sdkRegion                         | VIDAKYCSDKRegion    | Region: .indonesia or .malaysia                                                                  |
| passportCountryCode               | String?             | ISO 3166-1 alpha-3 code for passport scanning                                                    |
| enableDocAutoCapture              | Bool                | Enables/Disables autocapture throughout doc capture flows. Default is true                       |
| captureAdditionalImageWithFlash   | Bool                | If enabled captures 2 images, normal and with flash for material check                           |
| docAutoCaptureMinimumStableFrames | Int                 | Minimum valid frames for auto capture                                                            |
| docCaptureTimeout                 | TimeInterval        | Max time for each capture                                                                        |
| autoCapturePauseTimeout           | TimeInterval        | Max time at which if autocapture enabled, switching to manual pop up is shown                    |
| luminanceThreshold                | Float               | Threshold value to identify whether the image is dark or not. Range (0-1). default value is 0.23 |

### **VIDAKYCKeys**

```kotlin
///   - apiKey: API key provided by VIDA
    ///   - licenseKey: License key provided by VIDA
    ///   - clientId: Client ID provided by VIDA for ID Shield, If passed fraudshield will be used in the flows
    ///   - userId: user Id from the clients application. User ID from the client's application. Optional — if not provided, a default value is used.
@objc public class VIDAKYCKeys: NSObject {
    let apiKey: String
    let licenseKey: String
    let fraudShieldClientId: String?
    let userId: String?
}
```

### **VIDAKYCFlow**

```kotlin
public enum VIDAKYCFlow: Int {
    case idVerification
    case kyc
}
```

### **Detailed Configuration Guide:**

For comprehensive documentation on configuring the VIDA Liveness SDK, including all available parameters, UI customization options, and best practices, please refer to:

### **VIDA iOS SDK FraudShield/Liveness Configuration:**

1. Add shared activation key in the application’s Info.plist under vida\_activation\_key

```kotlin
<key>vida_activation_key</key>
<string>__activation_key_provided_by_vida__</string>
```

2. Configure the sdk with parameters within the `VIDALivenessConfig`

```kotlin
<key>vida_activation_key</key>
<string>__activation_key_provided_by_vida__</string>
```

Note: - For additional configuration details, checkout the liveness sdk integration guide - <https://docs.vida.id/vida-identity-platform/integration-methods/sdk/ios-sdk>

### **VIDAKYCDocumentType**

SDK currently supports the following documents:

<table><thead><tr><th width="289.6953125">ID Card Type</th><th>Description</th></tr></thead><tbody><tr><td>KTP</td><td>Indonesian National ID</td></tr><tr><td>DL</td><td>Driving License</td></tr><tr><td>myKAD</td><td>Malaysian ID Card</td></tr><tr><td>myKAS</td><td>Malaysian temporary resident identification card</td></tr><tr><td>myPR</td><td>Malaysian Permanent Resident ID Card</td></tr><tr><td>myTentera</td><td>Malaysian Military ID Card</td></tr><tr><td>Passport</td><td></td></tr></tbody></table>

### **VIDAKYCSDKRegion**

```kotlin
public enum VIDAKYCSDKRegion: Int {
    case indonesia
    case malaysia
}
```

### **VIDAKYCResponse**

The `VIDAKYCResponse` class encapsulates the results of the entire KYC verification process.

```kotlin
public class VIDAKYCResponse {
    public let livenessResponse: VIDALivenessResponse?
    public let ocrIdVerificationResponse: OCRIdVerificationResponse?
    public let faceVerificationResponse: FaceVerificationResponse?
    public let failedOperation: String?
}
```

The response serves as the final structured output from the VIDA SDK, passed via the `onSuccess()` or `onError()` callbacks in `VIDAKYCDelegate`. `failedOperation` will have ocrFront/ocrBack/liveness/faceMatch as the options.
