我使用以下代码在我的应用程序中对用户进行身份验证
let mycontext = LAContext()
let authenticatonString = ""
var authError :NSError? = nil
if #available(OSX 10.12, *) {
if mycontext.canEvaluatePolicy(LAPolicy.deviceOwnerAuthenticationWithBiometrics, error: &authError) {
mycontext.evaluatePolicy(LAPolicy.deviceOwnerAuthenticationWithBiometrics, localizedReason: authenticatonString, reply: { (sucess, evaluationError) in
if sucess == true {
self.resultLabel.stringValue = "authenticated successfully"
} else {
print("error reason : \(evaluationError?.localizedDescription)")
self.resultLabel.stringValue = (evaluationError?.localizedDescription)!
}
})
} else {
self.resultLabel.stringValue = "touch id not available; so show passcode dialog"
}
} else {
self.resultLabel.stringValue = "older version of osx; so show passcode dialog"
}
事件虽然触摸 id 方法可从 osx 10.12 获得,但这些canEvaluatePolicy
方法在 osx 10.12 和 10.12.1 中崩溃并出现错误
Error Domain=com.apple.LocalAuthentication Code=-1001 "Unknown policy: '1'" UserInfo={NSLocalizedDescription=Unknown policy: '1'}
LAPolicy.deviceOwnerAuthenticationWithBiometrics
也可从10.12
我想知道评估出了什么问题