3

This is not a dupe of: Can we test Face ID in simulator?

I want to know how to test when a user accepts the Face ID alert below that reads "Do you want to allow "app" to use Face ID" and then decides to disable Face ID for an app in the simulator.

Face ID Alert

Steve Moser
  • 7,169
  • 3
  • 49
  • 88

1 Answers1

3

When you run context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &authError) it will return false and an authError as Optional<NSError>:

Error Domain=com.apple.LocalAuthentication Code=-6 "User has denied 
the use of biometry for this app." UserInfo=
{NSLocalizedDescription=User has denied the use of biometry for this app.}

Use error.code for your tests, in this case it is -6, you can find more about LAError.Code codes in Apple docs

It is actually interesting topic: apparently, if a user did not give a permission for Face ID - only way to get it on a simulator is to reinstall the app. There is a discussion on Apple forum about it.

Vladimir
  • 165
  • 9
  • The sad thing is even if the user did not allow OR the device does not support biometry, the error code is the same (-6) biometryNotAvailable. There should be different error codes for user did not allow and device is not capable of biometry. – akshay1188 Dec 06 '19 at 17:15