# Usage

4Minimum Requirements

1. iOS 11

## Installation

Download our framework through [CocoaPods](http://cocoapods.org/?q=cryptoSwift)

```shell
pod 'ValifyEKYC', '~> 1.4.0'
```

## Authentication

In order to generate an access token that will be used in the SDK authentication settings, use our [authentication service API](https://valify.gitbook.io/documentation/general/oauth-token).

## Configuration

Add the following Add the following key to the app’s info.plist file

> Privacy - Camera Usage Description

Import the framework

```swift
import ValifyEKYC
```

Implement `valifyDelegate` to your class

```swift
class ViewController: UIViewController, valifyDelegate {
```

Confirm your class to the protocol

```swift
valify.sharedInstance.delegate = self
```

Configuring your SDK settings

```swift
let settings = valifyBuilder()

// Authentication (required)
.set(bundle: String)            // bundle id
.set(token: String)             // authentication token
.set(baseURL: String)

// (SDK flow)
.withTerms(_ withTerms: Bool)
.withTutorial(_ withTutorial: Bool)
.withOCR(_ withOCR: Bool)
.withDocumentVerification(_ withDocumentVerification: Bool)
.withWatermarkCheck(_ withWatermarkCheck: Bool)
.withDataUpdating(_ withDataUpdating: Bool)
.withLiveness(_ withLiveness: Bool)
.withFaceMatch(_ withFaceMatch: Bool)
.withRating(_ withRating: Bool)
.withoutPreviewData(_ withoutPreviewData: Bool)
.withoutPermissionsScreen(_ withoutPermissionsScreen: Bool)

// Language (optional) (default: English)
.set(language: valifyLanguage)

// FaceMatch settings (optional)
.withCustomFaceMatchTransactionID(transactionID: String)
.withCustomFaceMatchImage(customFaceMatchImage: UIImage)


// Liveness settings (optional)
.set(livenessNumOfInsructions: 2)
.set(livenessNumOfTrials: 4)
.set(livenessTimerSeconds: 30)
.withoutSmile(_ withoutSmile: Bool)
.withoutLookLeft(_ withoutLookLeft: Bool)
.withoutLookRight(_ withoutLookRight: Bool)
.withoutCloseEyes(_ withoutCloseEyes: Bool)

// (SDK flow)
.build()
```

{% hint style="warning" %}
Your app must support landscape orientation in order for our SDK to work properly. If you require your app views to be in portrait orientation only, you can use View-Based orientation lock in order to have your app views restricted to portrait mode.
{% endhint %}

If you use the Face Match service after the OCR or OCR w/ Verification service then the face in the front side image of the national ID captured during the OCR or OCR w/ Verification step will be used for comparison with the image captured during the Face Match step.

If you use the Face Match service separately, you need to either pass an image or a transactions id for a hit previously made to our OCR or OCR w/ Verification service for comparison with the image that will be captured for the user going through the SDK experience:

```swift
// FaceMatch settings (optional)
.withCustomFaceMatchTransactionID(transactionID: String)
.withCustomFaceMatchImage(customFaceMatchImage: UIImage)
```

Run the SDK (must be called after `viewDidAppear` has already been called, for example, in a button action)

```swift
let valifyRun = valifyFlow.init(withSettings: settings, fromViewController: self)

do {
      try valifyRun.run()
} catch {
      print(error)
}
```

When you implement `valifyDelegate` you’ll have to add the required method of the protocol

```swift
func didFinishProcess(_ valifyResponse: valifyResponse, _ valifyToken: String)
```

This `didFinishProcess` function will be called once the framework has finished, and it will return the session’s token and `valifyResponse` object which is an enumerator of the following cases

1. **success**: the user has completed the experience successfully. The Valify token (`valifyToken`), and the data collected ([`valifyResult`](/ios-sdk-documentation/ios/version-1.4.0/valifyresult-object.md)) are returned.
2. **userExited**: the user exits the SDK voluntarily returning to the main app. The Valify token (`valifyToken`), and ([`userExited`](/ios-sdk-documentation/ios/version-1.4.0/userexited-object.md)) object are returned to the app.
3. **error**: the user aborts as a result of an error. The Valify token (`valifyToken`), ([`valifyError`](/ios-sdk-documentation/ios/version-1.4.0/valifyerror-object.md)) are returned to the app.

## Demo Application

The following is a demo application that illustrates how to integrate the Valify eKYC SDK inside your application:

{% embed url="<https://gitlab.com/valify-public/valifyekycdemoapp>" %}

##


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://valify.gitbook.io/ios-sdk-documentation/ios/version-1.4.0/usage.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
