Tôi đang chạy Xcode 9 GM mới nhất (13/09/2017) và đã đặt Hardware > Face ID > Enrolled
trong trình mô phỏng cũng như Deployment Target 11.0
. Tuy nhiên tôi nhận được mã lỗi -6 LAErrorTouchIDNotAvailable
.iOS 11 Simulator không cho phép LAContext và FaceID
Có một số cài đặt tôi bị thiếu không?
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")
}
sử dụng thư viện này, nó hỗ trợ faceid và touchid cả . https://github.com/tejas-ardeshna/TJBioAuthentication –