简体   繁体   English

如何在模拟器中测试允许面部识别码和禁用面部识别码的面部识别?

[英]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? 这不是骗局: 我们可以在模拟器中测试Face ID吗?

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”的Face ID警报,然后决定在模拟器中禁用应用程序的Face ID。

面部识别警报

When you run context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &authError) it will return false and an authError as Optional<NSError> : 当您运行context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &authError) ,它将返回false并将authError作为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 使用error.code进行测试,在本例中为-6 ,您可以在Apple文档中找到有关LAError.Code代码的更多信息。

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. 这实际上是一个有趣的话题:显然,如果用户没有给Face ID许可 - 只有在模拟器上获取它的方法是重新安装应用程序。 There is a discussion on Apple forum about it. Apple论坛上有一个关于它的讨论。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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