【问题标题】:Is possible use only TouchID?可以只使用 TouchID 吗?
【发布时间】:2018-12-04 00:08:47
【问题描述】:

我正在向我的应用程序添加生物识别,但我只想使用 Touch ID,我想使用 Face IS。

有可能吗?或者使用 canEvaluatePolicy 我必须同时使用强制?

我正在使用此代码,但我看不到一种方法。

context.evaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason: "Logging in with Touch ID", reply: { (success : Bool, error : NSError? ) -> Void in
        dispatch_async(dispatch_get_main_queue(), {

        if success {
            let alert = UIAlertController(title: "Success", message: "", cancelButtonTitle: "Great!")
            self.presentViewController(alert, animated: true, completion: nil)
        }

        if let error = error {
            var message :String

            switch(error.code) {
            case LAError..AuthenticationFailed:
                message = "There was a problem verifying your identity."
            case LAError..UserCancel:
                message = "You pressed cancel."
            case LAError..UserFallback:
                message = "You pressed password."
            default:
                message = "Touch ID may not be configured"
            }

            let alert = UIAlertController(title: "Error", message: message, cancelButtonTitle: "Darn!")
            self.presentViewController(alert, animated: true, completion: nil)
        }

        context = LAContext()
    })
})

【问题讨论】:

  • 阻止 iPhone X* 用户(和新 iPad Pro 用户)使用其设备的生物识别功能是没有意义的。要么支持生物识别,要么不支持。给旗舰设备用户带来较少的体验并不是一个好主意。您应该避免引用“touchID”的硬编码字符串,因为它可能是人脸 ID

标签: ios swift touch-id lacontext


【解决方案1】:

我有同样的问题,但是当您实现代码以使用生物识别进行身份验证时。它是 Touch ID 或 Face ID,因此您无需担心要使用哪一个。因此,您的代码应该适用于触控 ID,例如 iPhone 6,适用于带有面容 ID 的 iPhone X。我希望这能回答你的问题。

【讨论】:

  • 感谢您的回复。部分原因是我询问是否可以取消该检查,尽管我知道这会限制 iPhone 用户。
猜你喜欢
  • 1970-01-01
  • 2012-02-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-10-30
  • 2019-09-04
  • 2012-07-03
相关资源
最近更新 更多