如何在我的应用程序中使用密码锁定场景? [英] How to use passcode lock scene in my app?

查看:74
本文介绍了如何在我的应用程序中使用密码锁定场景?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

实际上,我正在构建一个包含本地身份验证的应用程序.

Actually, I building an app which contains local authentication.

到目前为止,我的代码:

My code so far:

func authenticateUser() {
        let authenticationContext = LAContext()
        var error: NSError?
        let reasonString = "Touch the Touch ID sensor to unlock."

        // Check if the device can evaluate the policy.
        if authenticationContext.canEvaluatePolicy(LAPolicy.deviceOwnerAuthenticationWithBiometrics, error: &error) {

            authenticationContext.evaluatePolicy( .deviceOwnerAuthenticationWithBiometrics, localizedReason: reasonString, reply: { (success, evalPolicyError) in

                if success {
                    print("success")
                } else {
                    if let evaluateError = error as NSError? {
                        // enter password using system UI 
                    }

                }
            })

        } else {
            print("toch id not available")
           // enter password using system UI
        }
    }

我的问题是,当应用程序没有触摸ID或无效的指纹时,我想使用密码锁定场景.

My problem is I want to use the passcode lock scene when the app doesn't has touch ID or invalid finger print.

就像下面的图片一样:

我该怎么办?

推荐答案

在这一点上,恐怕您不能将此密码锁屏访问到您的应用程序中,它与iOS本身有关.您可能需要构建自己的自定义视图控制器,以使其看起来/表现为密码锁定场景(带有Touch ID).我个人建议使用一个库来实现此目的,我已经尝试过 PasscodeLock ,它可以正常工作对我来说.

At this point, I am afraid that you cannot access this passcode lock screen into your app, it is related to the iOS itself. You might need to build your own custom view controller to look/behave as the passcode lock scene (with Touch ID). I would suggest to use a library for achieving this, personally, I've tried PasscodeLock and it works fine for me.

这篇关于如何在我的应用程序中使用密码锁定场景?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆