LAContext(). BiometryType возвращает.none на iPhone X
У меня проблема с 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= Соединение со службой с именем com.apple.CoreAuthentication.daemon было недействительным в этом процессе.}
Он уже работал раньше, но теперь (без каких-либо изменений) он все еще возвращается .none
,
Вы столкнулись с той же ошибкой?
1 ответ
Вы не поделились полным сообщением об ошибке. Вот полное сообщение об ошибке:
[LAClient] initWithExistingContext -> (null), Error Domain = NSCocoaErrorDomain Code = 4099 "Подключение к службе с именем com.apple.CoreAuthentication.daemon было недействительным в этом процессе". UserInfo={NSDebugDescription= Соединение со службой с именем com.apple.CoreAuthentication.daemon было недействительным из этого процесса.} 2018-03-29 13:42:37.866753+0530 Test[1505:35036] [LAClient] initWithExistingContext -> (null), Error Domain=NSCocoaErrorDomain Code=4099 "Соединение с сервисом с именем com.apple.CoreAuthentication.daemon было недействительным в этом процессе." UserInfo={NSDebugDescription= Соединение со службой с именем 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
Посмотрите на этот снимок: