# Checking Liveness and Face Biometry

{% hint style="info" %}

## **If you use our SDK just for capturing videos, omit this step.**

{% endhint %}

## OzCapsula (SDK v8.22 and newer)

At the [Capturing Videos](https://doc.ozforensics.com/oz-knowledge/guides/developer-guide/sdk/oz-mobile-sdk/ios/pages/MhZCjAYwIhr8BZbk5YcT#ozcapsula-sdk-v8.22-and-newer) step you've created a data container with all the required information in it , so now just send it to analysis using the `addContainer(container)` and `run` methods.

```swift
func onResult(container: DataContainer) {
  let analysisRequest = AnalysisRequestBuilder()
  analysisRequest.addContainer(container)
  analysisRequest.run(
            statusHandler: { status in
            },
            errorHandler: { error in
            }
        ) { result in
        }
}
```

## SDK 8.21 and older

To check liveness and face biometry, you need to upload media to our system and then analyze them.

{% hint style="info" %}
To interpret the results of analyses, please refer to [Types of Analyses](/oz-knowledge/guides/developer-guide/api/oz-api/types-of-analyses-and-what-they-check.md).
{% endhint %}

Below, you'll see the example of performing a check and its description.

{% code lineNumbers="true" %}

```swift
let analysisRequest = AnalysisRequestBuilder()
// create one or more analyses
let analysis = Analysis.init(
	media: mediaToAnalyze, // mediaToAnalyze is an array of OzMedia that were captured or otherwise created
	type: .quality, // check the analysis types in iOS methods
	mode: .serverBased) // or .onDevice if you want the on-device analysis
analysisRequest.uploadMedia(mediaToAnalyze)
analysisRequest.addAnalysis(analysis)
// initiate the analyses
analysisRequest.run(
	statusHandler: { state in }, // scenario steps progress handler
	errorHandler: { _ in }  
) { result in
    // receive and handle analyses results here 
}
```

{% endcode %}

To delete media files after the checks are finished, use the `cleanTempDirectory` method.

### Adding Metadata

To add metadata to a folder, use `AnalysisRequest.addFolderMeta`.

```swift
let analysis = Analysis.init(media: mediaToAnalyze, type: .quality, mode: .serverBased)
var folderMeta: [String: Any] = ["key1": "value1"]
analysisRequest.addFolderMeta(folderMeta)
...
```

### Extracting the Best Shot

In the `params` field of the `Analysis` structure, you can pass any additional parameters (key + value), for instance, to extract the best shot on the server side.

```swift
let analysis = Analysis.init(media: mediaToAnalyze, type: .quality, mode: .serverBased, params: [“extract_best_shot” : true])
```

### Using Media from Another SDK

To use a media file that is captured with another SDK (not Oz iOS SDK), specify the path to it in the [OzMedia](https://doc.ozforensics.com/oz-knowledge/guides/developer-guide/sdk/oz-mobile-sdk/ios/pages/BVX89LL3HSWuDVvGUadK#h.hizmhq9c5cq9) structure (the `bestShotURL` property):

```swift
let referenceMedia = OZMedia.init(movement: .selfie,
                  mediaType: .movement,
                  metaData: ["meta":"data"],
                  videoURL: nil,
                  bestShotURL: imageUrl,
                  preferredMediaURL: nil,
                  timestamp: Date())
```

### Adding Media to a Certain Folder

If you want to add your media to the existing folder, use the `addFolderId` method:

```swift
let analysis = Analysis.init(media: mediaToAnalyze, type: .quality, mode: .serverBased)
analysisRequest.addFolderId(IdRequired)
```


---

# 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://doc.ozforensics.com/oz-knowledge/guides/developer-guide/sdk/oz-mobile-sdk/ios/checking-liveness-and-face-biometry.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.
