【问题标题】:Local Authentication on device with Passcode only, not TouchID仅使用密码而不是 TouchID 的设备上的本地身份验证
【发布时间】:2015-04-06 23:46:21
【问题描述】:

假设我的应用包含敏感数据,我想确保用户在访问之前通过密码在本地进行身份验证。如Xamarin intro to touch ID article 所示,我正在使用 iOS 8 的 Xamarin TouchID 身份验证。我在运行 iOS 7 的旧设备上对此进行了测试,但显然无法正常工作。所以我的问题是,如何使用 iOS 7 设备进行密码验证?这仅适用于 iOS 8 吗?


我注意到 iOS 应用 Mint 使用自定义密码。如何实现连接到 TouchID 弹出窗口中“输入密码”按钮的自定义密码?如果我知道该怎么做,我可以实现自己的自定义密码,以便它适用于 iOS 7...

【问题讨论】:

    标签: ios authentication ios7 xamarin touch-id


    【解决方案1】:

    iOS 7 无法使用 Touch ID。

    要使用自定义密码,只需在 evaluatePolicy 中捕获 LAErrorUserFallback 错误。

    LAContext *context = [[LAContext alloc] init];
    [context evaluatePolicy:LAPolicyDeviceOwnerAuthenticationWithBiometrics
                     localizedReason:@"Your Text" reply:^(BOOL success, NSError *error) {
                         if(success) {
                         // handle success
                         } else {
                             NSString *failureReason;
                             switch (error.code) {
                                 case LAErrorUserFallback:
                                    // show your custom passcode screen
                                     break;
                             } 
                         }
                     }];
    

    代码显然需要完成,您还需要处理所有其他错误情况。

    【讨论】:

    • +1 用于在 error.code 中包含 switch 语句以处理可能发生的所有不同情况
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-02-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-06-07
    • 1970-01-01
    • 2017-03-26
    相关资源
    最近更新 更多