代码之家  ›  专栏  ›  技术社区  ›  user3745888

只能使用TouchID吗?

  •  -2
  • user3745888  · 技术社区  · 6 年前

    有可能吗?或者使用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()
        })
    })
    
    1 回复  |  直到 6 年前
        1
  •  0
  •   emrepun    6 年前

    我也有同样的问题,但当你实现你的代码有生物认证。它要么是触摸ID要么是面部ID,所以你不必担心你想用哪一个。所以你的代码应该可以很好地处理touch ID,比如iPhone 6,也可以很好地处理iPhone X和face ID,我希望这能回答你的问题。