iOS (Compat) Liveness SDK
Our iOS SDK enables seamless integration of real-time liveness detection into your mobile applications. To get started with our SDK, follow the guide below:
Youverify Liveness SDK Compat is the compatibility version of the iOS SDK, designed for integrating active liveness detection into UIKit-based applications. This SDK is tailored for apps that need to support iOS 12 and later, providing a reliable solution for older iOS versions.
Features
Active Liveness Detection: Requires users to perform specific actions (e.g., head movements, answering questions) to confirm liveness. Available on iOS 12+.
Built with UIKit, ensuring compatibility with legacy iOS applications.
Note: Passive liveness detection is not supported in this version.
Installation
Step 1: Add to Podfile
Add the following to your Podfile
:
Step 2: Install Dependencies
Run this command in your terminal:
Step 3: Open Workspace
Open the generated .xcworkspace
file in Xcode.
Project Configuration
To avoid linker errors:
Open your project in Xcode.
Go to Project > Pods.
Under Other Linker Flags (
OTHER_LDFLAGS
) for both.debug
and.release
, ensure the following are not present:force-load
-framework mediaPipetaskvision
-framework mediataskCommon
Usage
1. Import the SDK
In your Swift file:
2. Initialize the SDK
Create an instance of YVLiveness
with your configuration:
The
publicKey
is dynamically retrieved from an environment variable (Environment.shared.value(forKey: "API_KEY") ?? ""
) in the working code. Replace this with your actual API key or retrieval logic.The
user
parameter requires afirstName
, while optional fields likelastName
andemail
can be added if needed (see Configuration Options).
3. Start Liveness Detection
Launch the SDK with a list of tasks:
4. Manage the Liveness View Controller
Add these methods to handle the liveness UI:
The
guard
statement inaddLivenessViewController()
prevents duplicate additions of the view controller.
5. Handle Modal Closing
Implement the delegate to close the liveness UI:
Configuration Options
publicKey
String
Yes
Your API key for authentication
-
Any string
user
Class
Yes
User details (requires firstName
)
-
See below
user.firstName
String
Yes
Userβs first name
-
Any string
user.lastName
String
No
Userβs last name
nil
Any string
user.email
String
No
Userβs email
nil
Any string
onSuccess
Function
No
Callback on success with liveness data
nil
Any function
onFailure
Function
No
Callback on failure with error data
nil
Any function
sandboxEnvironment
Bool
No
Toggle sandbox mode for testing
true
true
, false
Available Tasks
Tasks verify liveness through user interactions. Below are the supported options:
Complete The Circle
Users trace a circle with head movements.
difficulty
TaskDifficulty
No
Task difficulty
.medium
.easy
, .medium
, .hard
timeout
Number
No
Time (ms) before task fails
nil
Any milliseconds
Example:
Yes or No
Users answer questions by tilting their head (right = yes, left = no).
difficulty
TaskDifficulty
No
Task difficulty
.medium
.easy
, .medium
, .hard
timeout
Number
No
Time (ms) before task fails
nil
Any milliseconds
questions
Array
Yes
List of yes/no questions
-
See below
questions.question
String
Yes
Yes/no question
-
Any string
questions.answer
Bool
Yes
Correct answer
-
true
, false
questions.errorMessage
String
No
Message on wrong answer
nil
Any string
Example:
Motions
Users perform nods, blinks, or mouth movements.
difficulty
TaskDifficulty
No
Task difficulty
.medium
.easy
, .medium
, .hard
timeout
Number
No
Time (ms) before task fails
nil
Any milliseconds
maxNods
Int
No
Max nods to perform
5
Any number
maxBlinks
Int
No
Max blinks to perform
5
Any number
Example:
Liveness Data
The onSuccess
callback returns:
faceImage
String
Userβs face image
livenessClip
String
Video of liveness check
passed
Bool
True if passed, false if failed
metadata
Any
Metadata from initialization
The onFailure
callback returns error details as a string or object, depending on the issue.
Full Example
Hereβs the complete implementation from the working code:
Credits
This SDK is developed and maintained solely by Youverify
Last updated
Was this helpful?