简体   繁体   中英

How do I test allowing Face ID and disallowing Face ID for an app in the simulator?

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.

面部识别警报

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM