> For the complete documentation index, see [llms.txt](https://docs.vida.id/vida-identity-platform/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/vida-identity-platform/integration-methods/sdk/liveness-sdk/ios-sdk/getting-started.md).

# Getting Started

## **Prerequisites**

Getting Activation Key

In order to access the VIDA SDK, you will need a Activation Key

{% hint style="info" %}
**Contact Vida Support**

If you haven't got the Activation Key, you can reach out to [<mark style="color:blue;">VIDA support team.</mark>](mailto:support@vida.id)
{% endhint %}

### **Add the Required Permissions**

To access camera features, add the following key to your app's Info.plist file

```xml
<key>NSCameraUsageDescription</key>
<string>Description of why your app needs camera access</string>
```

### **Add the SDK as a Dependency**

To integrate `vidaLiveness`, utilize CocoaPods and incorporate the `VidaLiveness` pod URL as indicated below.

```ruby
#Production Environment

source 'https://bitbucket.org/vidaid/ios-sdk.git'

pod 'VidaLiveness', podspec:
'https://sdk-repo.vida.id/ios/vidaLiveness/X.Y.Z.podspec'
```

```ruby
#Sandbox Environment

source 'https://bitbucket.org/vidaid/ios-sdk.git'

pod 'VidaLiveness', podspec:
'https://sdk-repo.dev.vida.id/ios/vidaLiveness/X.Y.Z-Sandbox.podspec'
```

X.Y.Z is the version of the framework that you want to use.

### **Specify Framework Details in Your Application**

In your application's Info.plist file, provide the activation key.

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

## **Initializing the Framework:**

**Import vidaLiveness**

In your UIViewController subclass implementation file, start by importing the `vidaLiveness` framework at the top of the file. This step allows you to access the classes and functions provided by the framework.

```swift
import vidaLiveness
```

**Create an Instance**

Next, create an instance of the `VIDALiveness` class. This instance will be used to interact with the framework and perform liveness checks.

```swift
let vidaLiveness = VIDALiveness()
```

**Initialize the Framework**

Use the `initialize` API of the `VIDALiveness` class to set up the framework with all the required configuration options. This includes providing a `VIDALivenessRequest`, `SDKUIComponentConfig`, `DetectOptions`, specifying whether to show the tutorial flow, setting a delegate for receiving updates, and providing a navigation controller for presenting UI components.

```swift
vidaLiveness.initialize(
        vidaLivenessRequest: yourLivenessRequest,
        sdkUIComponentConfig: yourSDKUIComponentConfig,
        detectionOptions: yourDetectionOptions,
        shouldShowTutorialFlow: true, // Set to true if you want to show the tutorial screen
        shouldShowReviewScreen: true // Set to true if you want to show the review screen
        languageCode: yourLanguageString, //ISO-639-1 code for the language
        delegate: yourDelegate,
        presentNavigationController: yourNavigationController
    )
```

### VIDALivenessRequest

init(from: Decoder)&#x20;

Properties&#x20;

**`var apiKey: String?`**&#x20;

API key provided by VIDA. This is a required parameter.&#x20;

**`var eKYCID: String?`**&#x20;

ID for the user’s eKYC for which the liveness is to be done.&#x20;

**`var licenseKey: String?`**&#x20;

License key provided by VIDA. This is a required parameter

### VIDAFaceDetectionOptions

Configuration options for the liveness detection.

```swift
init(detectionTimeout: Int, minimumStableFrame: Int, eyeOpenProbability: Float)
```

### SDKUIComponentConfig

The `SDKUIComponentConfig` helps in configuring the UI. The detailed guide on configuration is available in [UI Customization through AP](broken://pages/8fDkFt36BjZu6VlTiUZI)[I](broken://pages/8fDkFt36BjZu6VlTiUZI) section.

### **Using the Framework for Liveness**

**Starting Liveness Flow:** Once the framework is initialized, you can initiate the liveness verification process by calling the `startDetection()` API. This will activate the camera and guide the user through the liveness check.

```swift
vidaLiveness.startDetection()
```

**Completing Liveness Check:** After the user has completed the liveness check, ensure to release the instance of `VIDALiveness` to free up resources. Use the `release()` API for this purpose.

```swift
vidaLiveness.release()
```

{% hint style="info" %}
The `vidaLiveness` iOS framework is compatible with iOS v13 and above, only on physical devices.
{% endhint %}

### The VIDALivenessProtocol

The VIDALivenessProtocol is designed to manage the lifecycle and events of the VIDALiveness flow and returns appropriate values via the delegate.

### **onError**&#x20;

This method is invoked when an error occurs during the liveness flow.

```swift
onError (errorCode: Int, errorMessage: String, response: VIDALivenessResponse)
```

#### **Parameters**

* **errorCode**: An integer representing the error code.
* **errorMessage**: A string message detailing the error.&#x20;
* **response**:   Contains final frame of liveness flow, various scores as applicable/available and error details if available.

### **onInitialized()**

This method is called when the VIDALiveness has been successfully initialized after the`initialize(vidaLivenessRequest:sdkUIComponentConfig:detectionOptions:shouldShowTutorialFlow:delegate:presentNavigationController:)`method is called.&#x20;

Any subsequent API calls related to the liveness flow should be made only after this method is triggered.

### **onSuccess**

This method is triggered upon successful completion of the liveness flow.

```swift
onSuccess(response: VIDALivenessResponse)
```

**Parameters**

* **response**: Contains final frame of liveness flow and various scores as applicable/available.

## VIDALivenessResponse

VIDALivenessResponse is triggered upon successful completion of the liveness flow. It contains the final frame of the liveness flow and various scores as applicable/available.

### imageData

Retrieves the final frame of the liveness flow, which was captured after the completion of liveness. The value will be returned as `null` in case of errors

```swift
var imageData: Data?
```

### livenessScore

Liveness score indicating the likelihood that the image is of a live person. Score for the liveness will be in the range between 0 to 1. The default score of -1 will be sent if its not applicable.

```swift
var livenessScore: Double
```

### manipulationScore

Image Manipulation score indicates the likelihood that the image has been manipulated or altered. Score for the image manipulation will be in the range between 0 to 1. The default score of -1 will be sent if its not applicable.

```java
var manipulationScore: Double
```

### errorDetails

Retrieves details about any error that occurred during liveness detection. Includes details about the error that occurred, or `null` if no error occurred.

```swift
var errorDetails: String?
```

### transactionId

Retrieves the transaction ID of the LivenessDetection event.

```swift
var transactionId: String?
```
