首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >LAContext().biometryType在iPhone X上返回.none

LAContext().biometryType在iPhone X上返回.none
EN

Stack Overflow用户
提问于 2018-03-28 15:34:38
回答 1查看 1.9K关注 0票数 3

我正面临着CoreAuthentication的一个问题。

我按照文档的要求调用了canEvaluatePolicy:error:,但结果始终是.none

代码语言:javascript
复制
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

您是否遇到过同样的错误?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 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的单个实例。

试试这个,看看:

代码语言:javascript
复制
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

看一下这个快照:

票数 4
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/49538623

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档