Skip to main content
The Youverify iOS SDK lets you add anti-deepfake liveness detection to your iPhone and iPad applications using Swift. Users are guided through a brief head-movement task that confirms a live person — not a spoofed image or video — is completing the verification. Before initializing the SDK you must generate a session ID and a liveness token from your backend.

Current version

The latest iOS Liveness SDK compact version is 0.1.5. A compatibility version is also available for older integrations.

Prerequisites

  • iOS minimum deployment target: iOS 13.0
  • Camera permission declared (NSCameraUsageDescription in Info.plist)
  • Swift 5.x or later

Step 1 — Add the SDK

Add the pod to your Podfile:
Then run:

Step 2 — Declare the camera permission

Add the following key to your Info.plist:

Step 3 — Generate tokens server-side

Before initializing the SDK your backend must generate a session ID and a liveness token. Use the ApiClient helper below as a reference for the required calls. Generate session ID — POST /v2/api/sdk/session-id:
Generate liveness token — POST /v2/api/sdk/liveness-token:
Never embed your API secret key in your iOS app. Make these requests from your server and pass only the resulting sessionId and authToken to your app.

Step 4 — Initialize and launch the SDK

1

Import the package

2

Initialize the SDK with tokens

3

Start the liveness task

4

Add the liveness view controller

5

Handle the close delegate

Available liveness tasks

All tasks accept a difficulty parameter (.easy, .medium, .hard) and an optional timeout in milliseconds.

Configuration options

String
Your Youverify public merchant key. Safe to embed in your app.
String
required
Session ID generated server-side via POST /v2/api/sdk/session-id.
String
required
Liveness token generated server-side via POST /v2/api/sdk/liveness-token.
Bool
default:"true"
Set to false for production. Defaults to true.
YVLivenessUser
User details. firstName is required; lastName and email are optional.
Bool
default:"false"
Set to true to enable audio narration of task instructions.

Callback data (LivenessData)

Bool
true if the liveness check passed all tasks.
String
URL or base64-encoded face image captured during the check.
String
URL or base64 video clip of the user performing the liveness task.
LivenessError
Present only on failure. Contains key (e.g. eyes_closed, image_capture_failed, invalid_or_expired_session) and message.

iOS (Compat) version

A compatibility version of the SDK is available for integrations requiring support for older iOS versions or legacy codebases. Install it via CocoaPods:
The compat version shares the same initialization API as the standard compact SDK.
If you receive an invalid_or_expired_session error, your session ID has expired. Generate a new sessionId and sessionToken from your backend and call initializeSDK again with the fresh values.