用户验证 iOS SDK
功能
要求
- iOS 12.0+
- Xcode 14.3+
设置
CocoaPods
CocoaPods 是 Cocoa 项目的依赖管理器。有关用法和安装说明,请访问他们的网站。要使用 CocoaPods 将 UserVerification
集成到您的 Xcode 项目中,在 Podfile
中指定它
pod 'UserVerification'
用法
初始化
在 AppDelegate 的 didFinishLaunchingWithOptions 方法中初始化 UserVerification
import UserVerification
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
UserVerification.shared.config(storeId: 'STORE_ID', storePassword: 'STORE_PASSWORD', production: true/false)
return true
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
UserVerification.shared.scanID(preview: self.mView.scannerUIView, countryCode: countryCode, documentType: docType, flipIntervalTime: 3.0, delegate: self)
UserVerification.shared.startSession()
}
extension My_ViewController: IdVerificationDelegate {
func onStart() {
// Session started
}
func onCardFlip() {
// Document flip instruction to scan back side
}
func onSuccess(userId: String) {
// Document verification succeed, a 'userid' will be returned
}
func onFailure(code: Int, error: String) {
// Document verification failed with code and an error message
}
func onValidCapture(image: UIImage, isFront: Bool) {
// On successfull document capture, an image will return for front/back side
}
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
UserVerification.shared.verifyUser(preview: self.mView.scannerUIView, userId: scannedUserId, delegate: self)
UserVerification.shared.startSession()
}
extension My_ViewController: UserVerificationDelegate{
func onStart() {
// Session started
}
func onInstruction(faceAngle: FaceAngle) {
// Face movement instruction (Left/Right/Center)
}
func onSuccess() {
// Face verification succeed
}
func onFailure(code: Int, error: String) {
// Face verification failed with code and an error message
}
func onValidCapture(image: UIImage, faceAngle: FaceAngle) {
// On successfull face capture, an image will return for perpective angle movement
}
}
override func viewWillDisappear(_ animated: Bool) {
super.viewWillDisappear(animated)
UserVerification.shared.stopSession()
}