我正面临着CoreAuthentication的一个问题。
我按照文档的要求调用了canEvaluatePolicy:error:,但结果始终是.none。
fileprivate let biometricsType: SecurityBiometrics = {
var error: NSError?
let evaluated = LAContext().canEvaluatePolicy(LAPolicy.deviceOwnerAuthenticationWithBiometrics, error: &error)
if #available(iOS 11.0, *) {
if LAContext().biometryType == .faceID { return .faceID }
if LAContext().biometryType == .touchID { return .touchID }
} else {
if (evaluated || (error?.code != LAError.touchIDNotAvailable.rawValue)) {
return .touchID
}
}
return .none
}()
// biometricsType returns `.none`控制台上出现了一个错误:
LAClient initWithExistingContext -> (null),Error Domain=NSCocoaErrorDomain Code=4099“与名为com.apple.CoreAuthentication.daemon的服务的连接在此进程中无效。”UserInfo={NSDebugDescription=The连接到名为com.apple.CoreAuthentication.daemon的服务在此进程中无效。
它以前已经起作用了,但是现在(没有任何改变)它仍然返回.none。
您是否遇到过同样的错误?
发布于 2018-03-29 08:20:07
您没有共享完整的错误消息。以下是完整的错误消息:
LAClient initWithExistingContext -> (null),Error Domain=NSCocoaErrorDomain Code=4099“与名为com.apple.CoreAuthentication.daemon的服务的连接在此进程中无效。”UserInfo={NSDebugDescription=The连接到名为com.apple.CoreAuthentication.daemon的服务在此进程中无效。} 2018-03-29 13:42:37.866753+0530 Test1505:35036 initWithExistingContext -> (null),Error Domain=NSCocoaErrorDomain Code=4099“指向名为com.apple.CoreAuthentication.daemon的服务的连接从此进程无效”。UserInfo={NSDebugDescription=The连接到名为com.apple.CoreAuthentication.daemon的服务在此进程中无效。
在普通语言中,它表示LAContext()在代码块中每次初始化([LAClient] initWithExistingContext -> (null))时都有问题。使用LAContext的单个实例。
试试这个,看看:
fileprivate let biometricsType: LABiometryType = {
let laContext = LAContext()
var error: NSError?
let evaluated = laContext.canEvaluatePolicy(LAPolicy.deviceOwnerAuthenticationWithBiometrics, error: &error)
if let laError = error {
print("laError - \(laError)")
return .none
}
if #available(iOS 11.0, *) {
if laContext.biometryType == .faceID { return .faceID }
if laContext.biometryType == .touchID { return .touchID }
} else {
if (evaluated || (error?.code != LAError.touchIDNotAvailable.rawValue)) {
return .touchID
}
}
return .none
}()
// print biometricsType
print("biometricsType - \(biometricsType.rawValue)")结果: biometricsType -2
看一下这个快照:

https://stackoverflow.com/questions/49538623
复制相似问题