> For the complete documentation index, see [llms.txt](https://docs.facephi.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.facephi.com/docs.facephi-en/sdks/sdk-mobile/ios-sdk/inicializacion/integracion-idv-mobile.md).

# Integration IDV Mobile

## What is IDV Mobile

**IDV (Identity Verification)** is the Flow that allows verifying and authenticating a person's identity through the capture and validation of **biometric traits**.

The Flow is configured beforehand on the **Facephi platform** and is executed in the application through its identifier (`flowId`).

## Required dependencies

Below is the detailed list of dependencies for the available components to integrate an IDV Flow in iOS. Install only the capture components that have been licensed.

### CocoaPods

```sh
// CORE
pod 'FPHISDKMainComponent', '~> $VERSION'
pod 'FPHISDKTrackingComponent', '~> $VERSION'
// CAPTURE COMPONENTS
pod 'FPHISDKSelphIDComponent', '~> $VERSION'
pod 'FPHISDKSelphiComponent', '~> $VERSION'
pod 'FPHISDKNFCComponent', '~> $VERSION'
pod 'FPHISDKCaptureComponent', '~> $VERSION'
pod 'FPHISDKVideoRecordingComponent', '~> $VERSION'
```

### Swift Package Manager (SPM)

```sh
// CORE
git@github.com:facephi-clienters/SDK-SdkPackage-SPM.git
git@github.com:facephi-clienters/SDK-TrackingPackage-SPM.git
// CAPTURE COMPONENTS
git@github.com:facephi-clienters/SDK-SelphidMBSDRComponent-SPM.git
git@github.com:facephi-clienters/SDK-Selphi_component-SPM.git
git@github.com:facephi-clienters/SDK-NFC_component-SPM.git
git@github.com:facephi-clienters/SDK-VideoRecording-SPM.git
git@github.com:facephi-clienters/SDK-CapturePackage-SPM.git
```

## Optional dependencies

The SDK includes several libraries that add functionality.

* Status -> Allows the SDK to display tutorial and diagnostic screens for each component, improving the user experience.
* Tokenize -> Some services require the sending of tokenized assets. This library adds the tokenized values to the component response.

### CocoaPods

```sh
pod 'FPHISDKStatusComponent', '~> $VERSION'
pod 'FPHISDKTokenizeComponent', '~> $VERSION'
```

### Swift Package Manager (SPM)

```sh
git@github.com:facephi-clienters/SDK-StatusPackage-SPM.git
git@github.com:facephi-clienters/SDK-TokenizePackage-SPM.git
```

## Initialize the SDK

The SDK works through a **main controller (`SDKController`)**, which must be correctly initialized before any Flow can be launched.

Facephi will provide the `apiKey` License required for Initialization.

After a successful Initialization, the application will have access to **all Flows configured for that project**.

```swift
SDKController.shared.initSdk(
        licensingUrl: SdkConfigurationManager.LICENSING_URL,
        apiKey: SdkConfigurationManager.APIKEY_LICENSING_IDV,
        output: { sdkResult in
            if sdkResult.finishStatus == .STATUS_OK {
                self.log("Automatic license set correctly")
            } else {
                self.log("An error occurred while trying to obtain the license: \(sdkResult.errorType)")
            }
        },
        trackingController: trackingController,
        tokenizeController: tokenizeController,
        statusController: statusController,
        analyticsOutput: { time, component, type, info  in
            self.log("Analytics: \(Date()) \(component) - \(type) - \(info)")
        })
```

## Launch an IDV Flow <a href="#lanzamiento-de-idv" id="lanzamiento-de-idv"></a>

The IDV Flow is launched through a `FlowController`, indicating:

* The **Flow ID** configured on the platform (`flowId`).
* The **Customer ID** (`customerId`).
* The **authentication ID** (`authenticationId`). Only necessary if we are dealing with an authentication Flow.
* The list of **controllers** that can participate in the process.

Common controller examples:

* `SelphiController` → Face Capture.
* `SelphIDController` → Document capture.
* `StartVideoRecordingController` / `StopVideoRecordingController` → Process recording.

```swift
public func launchFlow(viewController: UIViewController, output: @escaping (SdkFlowResult) -> Void) {
        let selphidController = SelphIDController(data: nil, output: {
            print("SelphidController output: \($0.errorType)")
        }, viewController: viewController)
        
        let selphiController = SelphiController(data: nil, output: {
            print("SelphiController output: \($0.errorType)")
        }, viewController: viewController)
        
        let startVideoRecordingController = VideoRecordingController(viewController: viewController, output: {
            print("videoRecordingController output: \($0.errorType)")
        })
        
        let stopVideoRecordingController = StopVideoRecordingController(videoRecordingController: startVideoRecordingController, output: {
            print("stopVideoRecordingController output: \($0.errorType)")
        })
        
        let controllers: [IFlowableController] =
        [selphidController, selphiController, startVideoRecordingController, stopVideoRecordingController]
        
        let flowConfigurationData = FlowConfigurationData(
            id: 340260c3-0428-41d7-91c7-13c2a122cfc3,
            controllers: controllers,
            customerId: SdkConfigurationManager.customerId,
            authenticationId: authenticationId) // Optional parameter
        
        let flowController = SdkConfigurationManager.offlineFlow ? FlowOfflineController(flowConfigurationData: flowConfigurationData, output: output): FlowController(flowConfigurationData: flowConfigurationData, output: output)
        self.flowController = flowController
        SDKController.shared.launch(controller: flowController)
}
```

## Check available Flows

If you need to retrieve the available Flows before launching one of them, use:

```kotlin
SDKController.shared.getFlowIds()
```

The function returns a list with the **Flow identifier** and its **operation type**.
