【发布时间】:2017-09-13 03:10:29
【问题描述】:
我正在运行最新的 Xcode 9 GM(2017 年 9 月 13 日)并在模拟器中设置了 Hardware > Face ID > Enrolled 以及 Deployment Target 11.0。但是我收到错误代码 -6 LAErrorTouchIDNotAvailable。
我缺少一些设置吗?
let myContext = LAContext()
let myLocalizedReasonString = "You are pretty"
var authError: NSError?
if #available(iOS 8.0, macOS 10.12.1, *) {
if myContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &authError) {
myContext.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: myLocalizedReasonString) { success, evaluateError in
if success {
print("// User authenticated successfully, take appropriate action")
} else {
print(" // User did not authenticate successfully, look at error and take appropriate action")
}
}
} else {
print(" // Could not evaluate policy; look at authError and present an appropriate message to user")
}
} else {
print(" // Fallback on earlier versions")
}
【问题讨论】:
-
使用这个库,它同时支持faceid和touchid。 github.com/tejas-ardeshna/TJBioAuthentication
标签: ios ios-simulator ios11 iphone-x face-id