【问题标题】:How to fallback to password authentication when Touch ID fails on iOS 8?当 iOS 8 上的 Touch ID 失败时如何回退到密码验证?
【发布时间】:2017-09-13 19:32:54
【问题描述】:

我正在尝试在我的应用上实施 Touch ID 身份验证,如果失败(或不可用),我想回退到密码。

这是我的代码:

 LAContext *ctx = [[LAContext alloc] init];
 [ctx evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics localizedReason:@"Authenticate to access." reply:^(BOOL success, NSError *error) {
        if(success){
            [...]
        }else if(error.code != LAErrorUserFallback){
            [...] //error handler
        }
    }];

当我使用 Touch ID 进行身份验证时,调用成功。当我在 3 次触摸后无法进行身份验证时,将调用错误处理程序。到这里都没问题。但是当我点击输入密码时,它应该显示输入密码屏幕,但没有任何反应。如何显示输入密码屏幕?

【问题讨论】:

    标签: ios authentication ios8 touch-id


    【解决方案1】:

    你应该使用 LAPolicyDeviceOwnerAuthentication 而不是 LAPolicyDeviceOwnerAuthenticationWithBiometrics 用于LAContext`s Method

    评估政策: 本地化原因:kReasonTitle: 回复

    canEvaluatePolicy: 错误:

    LAPolicyDeviceOwnerAuthentication:

    如果 Touch ID 可用、已注册且未锁定,则首先要求用户输入它,否则要求他们输入设备密码这将显示输入密码屏幕

    【讨论】:

      【解决方案2】:

      您应该首先通过调用LAContext's [canEvaluatePolicy:error:] 方法检查TouchID 是否可用,如果TouchID 不可用,该方法将返回NO

      而 LAErrorUserFallback 适用于 YOUR 应用程序自己的密码(身份验证)方案,而不是设备。 More information can be found here in this related question.

      【讨论】:

      【解决方案3】:

      使用LAPolicyDeviceOwnerAuthentication 代替LAPolicyDeviceOwnerAuthenticationWithBiometrics

      如果可用,它将首先提示输入 Touch ID 并将其注册到设备上。如果您错误地使用了 3 次 Touch ID,则会显示“输入密码”按钮。点击该按钮后,将显示设备密码屏幕。

      【讨论】:

        猜你喜欢
        • 2015-03-22
        • 1970-01-01
        • 2020-09-21
        • 2015-04-19
        • 2015-09-10
        • 1970-01-01
        • 2018-05-16
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多