-2

I'm adding biometric to my application but I want only use Touch ID, I want's use Face IS.

Is it possible? Or using canEvaluatePolicy I have to use compulsory both?

I'm using this code, but I can't see one way to do this.

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()
    })
})
rmaddy
  • 314,917
  • 42
  • 532
  • 579
user3745888
  • 6,143
  • 15
  • 48
  • 97
  • 1
    It doesn't make sense to preclude iPhone X* users (and new iPad Pro users) from using the biometric features of their device. Either support biometrics or don't. Giving flagship device users a lesser experience isn't a good idea. You should avoid hard-coded strings referring to "touchID" as it may be face id – Paulw11 Dec 04 '18 at 00:33

1 Answers1

0

I had the same question, but when you implement your code to have authentication with biometrics. It is either touch ID or Face ID, so you dont need to worry about which one you want to use. So your code should work fine with touch ID for example with iPhone 6, and fine with iPhone X with face ID. I hope this answers your question.

emrepun
  • 2,496
  • 2
  • 15
  • 33
  • Thanks for the reply. Partially, because I asked if that check could be eliminated, although I know that this would limit the iPhone users. – user3745888 Dec 04 '18 at 07:12