Touch ID - 如何进入密码屏幕? -迅速

时间:2015-12-09 17:22:55

标签: ios iphone swift touch-id

所以我一直在搜索stackoverflow,我无法找到答案。当用户点击“输入密码”时,如何允许用户访问内置的Apple密码屏幕?请单击下面提供的链接以查看此问题的图像说明。感谢您的帮助,请在Swift中写一下!

http://i.stack.imgur.com/id9E3.jpg

1 个答案:

答案 0 :(得分:11)

这可以通过iOS 9来完成,它会公开新的LAPolicy类型,即在调用evaluatePolicy时,传递DeviceOwnerAuthentication {{1 }}

这里有一些快速:

DeviceOwnerAuthenticationWithBiometrics

现在,当用户用错误的手指点击主页按钮时,警告框将显示“输入密码”选项:

enter image description here

点击import LocalAuthentication function authenticateUser() { let context = LAContext() context.evaluatePolicy(LAPolicy.DeviceOwnerAuthentication, localizedReason: "Please authenticate to proceed.") { [weak self] (success, error) in guard success else { dispatch_async(dispatch_get_main_queue()) { // show something here to block the user from continuing } return } dispatch_async(dispatch_get_main_queue()) { // do something here to continue loading your app, e.g. call a delegate method } } } 会显示两个提示之一,具体取决于用户是否设置了数字或字母数字密码:

数字密码:

numeric passcode

字母数字密码:

alphanumeric passcode