> 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/products/idv-suite/flujos-and-integraciones/configuracion-tecnica-del-cliente/sdk-mobile/ios-sdk/inicializacion.md).

# Initialization

## 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 in the **Facephi platform** and it is executed in the application through its identifier (`flowId`).

## Required dependencies

Below is the 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'
pod 'FPHISDKStatusComponent', '~> $VERSION'
pod 'FPHISDKTokenizeComponent', '~> $VERSION'
// CAPTURE COMPONENTS
pod 'FPHISDKSelphIDComponent', '~> $VERSION'
pod 'FPHISDKSelphiComponent', '~> $VERSION'
pod 'FPHISDKNFCComponent', '~> $VERSION'
pod 'FPHISDKCaptureComponent', '~> $VERSION'
pod 'FPHISDKVideoRecordingComponent', '~> $VERSION'
```

To facilitate the integration process, a table is provided as evidence, which refers to the dependency of each component:

<table><thead><tr><th>Component</th><th width="259.15625">Dependency</th><th>Controller</th></tr></thead><tbody><tr><td>Selfie</td><td>FPHISDKSelphiComponent</td><td><code>SelphiController</code></td></tr><tr><td>Selfie (with IAD functionality)</td><td>FPHISDKSelphiIADComponent</td><td><code>SelphiController</code></td></tr><tr><td>Document</td><td>FPHISDKSelphIDComponent</td><td><code>SelphIDController</code></td></tr><tr><td>Video recording</td><td>FPHISDKVideoRecordingComponent</td><td><code>VideoRecordingController</code> / <code>StopVideoRecordingController</code></td></tr><tr><td>NFC</td><td>FPHISDKNFCComponent</td><td><code>NFCController</code></td></tr></tbody></table>

### Swift Package Manager (SPM)

```sh
// CORE (REQUIRED)
git@github.com:facephi-clienters/SDK-SdkPackage-SPM.git
git@github.com:facephi-clienters/SDK-TrackingPackage-SPM.git
git@github.com:facephi-clienters/SDK-StatusPackage-SPM.git
git@github.com:facephi-clienters/SDK-TokenizePackage-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
```

To facilitate the integration process, a table is provided as evidence, which refers to the dependency of each component:

<table><thead><tr><th width="178.30078125">Component</th><th width="296.1875">Dependency</th><th>Controller</th></tr></thead><tbody><tr><td>Selfie</td><td>git@github.com:facephi-clienters/SDK-Selphi_component-SPM.git</td><td><code>SelphiController</code></td></tr><tr><td>Selfie (with IAD functionality)</td><td>git@github.com:facephi-clienters/SDK-Selphi_IAD<em>_</em>component-SPM.git</td><td><code>SelphiController</code></td></tr><tr><td>Document</td><td>git@github.com:facephi-clienters/SDK-SelphidMBSDRComponent-SPM.git</td><td><code>SelphIDController</code></td></tr><tr><td>Video recording</td><td>git@github.com:facephi-clienters/SDK-VideoRecording-SPM.git</td><td><code>VideoRecordingController</code> / <code>StopVideoRecordingController</code></td></tr><tr><td>NFC</td><td>git@github.com:facephi-clienters/SDK-NFC_component-SPM.git</td><td><code>NFCController</code></td></tr></tbody></table>

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.

## Initialize the SDK

The SDK works through a **main controller (`SDKController`)**, which must be initialized correctly 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
let trackingController = TrackingController(trackingError: { trackingError in
    print("TRACKING ERROR: \(trackingError)")
}, enableLocation: enableLocation, debug: debugFlag)

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 in the platform (`flowId`).
* The **Customer ID** (`customerId`).
* The **Authentication ID** (`authenticationId`). Only necessary if this is an authentication flow.
* The list of **controllers** that can participate in the process.

Examples of common controllers:

* `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) // 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 obtain 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**.
