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:
pod 'YouverifyLivenessSDKCompat'
pod 'MediaPipeTaskVision'
Step 2: Install Dependencies
Run this command in your terminal:
pod install
Step 3: Open Workspace
Open the generated .xcworkspace file in Xcode.
Project Configuration
To prevent linker errors, add the following post-install script to your application's Podfile, making sure to replace "YourAppTarget" with the correct target name for your app.
post_install do |installer|
target_name = "YourAppTarget"
# Get the paths to the xcconfig files
debug_xcconfig_path = "#{installer.pods_project.project_dir}/Target Support Files/Pods-#{target_name}/Pods-#{target_name}.debug.xcconfig"
release_xcconfig_path = "#{installer.pods_project.project_dir}/Target Support Files/Pods-#{target_name}/Pods-#{target_name}.release.xcconfig"
# Modify the debug .xcconfig file if it exists
if File.exist?(debug_xcconfig_path)
puts "Modifying debug .xcconfig file: #{debug_xcconfig_path}"
# Read the debug .xcconfig file
debug_xcconfig = File.read(debug_xcconfig_path)
# Remove framework flags from OTHER_LDFLAGS
debug_xcconfig.gsub!(/-framework\s+"MediaPipeTasksCommon"/, '')
debug_xcconfig.gsub!(/-framework\s+"MediaPipeTasksVision"/, '')
# Remove -force_load from OTHER_LDFLAGS for iphoneos and iphonesimulator
debug_xcconfig.gsub!(/-force_load\s+"?[^"]*libMediaPipeTasksCommon.*\.a"?/, '')
# Write the modified debug .xcconfig file
File.write(debug_xcconfig_path, debug_xcconfig)
puts "Modified debug .xcconfig file."
else
puts "Debug .xcconfig file not found at #{debug_xcconfig_path}"
end
# Modify the release .xcconfig file if it exists
if File.exist?(release_xcconfig_path)
puts "Modifying release .xcconfig file: #{release_xcconfig_path}"
# Read the release .xcconfig file
release_xcconfig = File.read(release_xcconfig_path)
# Remove framework flags from OTHER_LDFLAGS
release_xcconfig.gsub!(/-framework\s+"MediaPipeTasksCommon"/, '')
release_xcconfig.gsub!(/-framework\s+"MediaPipeTasksVision"/, '')
# Remove -force_load from OTHER_LDFLAGS for iphoneos and iphonesimulator
release_xcconfig.gsub!(/-force_load\s+"?[^"]*libMediaPipeTasksCommon.*\.a"?/, '')
# Write the modified release .xcconfig file
File.write(release_xcconfig_path, release_xcconfig)
puts "Modified release .xcconfig file."
else
puts "Release .xcconfig file not found at #{release_xcconfig_path}"
end
end
Usage
1. Import the SDK
In your Swift file:
import YouverifyLivenessSDK
2. Initialize the SDK
Create an instance of YVLiveness with your configuration:
private var yvLiveness = YVLiveness(
publicKey: Environment.shared.value(forKey: "API_KEY") ?? "",
user: YVLivenessUser(firstName: "Ugochukwu"),
onSuccess: { data in
print("The success data is \(data)")
},
onFailure: { errorData in
print("The error data is \(errorData)")
},
sandboxEnvironment: false
)
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 a firstName, while optional fields like lastName and email can be added if needed (see Configuration Options).