iOS调用TouchID代码:
override func viewDidLoad() {
super.viewDidLoad()
let context = LAContext()
var error: NSError? = nil
let canEvaluatePolicy = context.canEvaluatePolicy(LAPolicy.deviceOwnerAuthenticationWithBiometrics, error: &error) as Bool
if error != nil {
print(error!.localizedDescription as String)
}
if canEvaluatePolicy {
print("有指纹验证功能")
context.evaluatePolicy(LAPolicy.deviceOwnerAuthenticationWithBiometrics, localizedReason: "放上您的狗爪", reply: { (success: Bool, error: Error?) in
if success {
print("验证成功")
} else {
print("验证失败: \(error?.localizedDescription)")
}
})
} else {
print("还没开启指纹验证呢")
}
}