我使用以下代码在我的应用程序中验证用户
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"
}
虽然osx 10.12提供了touch id方法,但是canEvaluatePolicy
方法在osx 10.12和10.12.1中崩溃并出现错误
Error Domain=com.apple.LocalAuthentication Code=-1001 "Unknown policy: '1'" UserInfo={NSLocalizedDescription=Unknown policy: '1'}
{10}也提供LAPolicy.deviceOwnerAuthenticationWithBiometrics
我想知道评估出了什么问题