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

Jak*_*keC 6 iphone ios touch-id swift

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

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

小智 13

这可以通过iOS 9来完成,它暴露了一种新LAPolicy类型,即在调用时evaluatePolicy,传入DeviceOwnerAuthentication 传入DeviceOwnerAuthenticationWithBiometrics.

这里有一些快速:

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
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

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

在此输入图像描述

点击Enter Passcode将显示两个提示之一,具体取决于用户是否设置了数字或字母数字密码:

数字密码:

数字密码

字母数字密码:

字母数字密码