我已经运行了最新的Xcode 9 GM(2017年9月13日),并在模拟器中设置了Hardware > Face ID > Enrolled
以及Deployment Target 11.0
。但是,我收到错误代码-6 LAErrorTouchIDNotAvailable
。iOS 11模拟器不支持LAContext和FaceID
有一些设置我错过了吗?
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都。 https://github.com/tejas-ardeshna/TJBioAuthentication –