• Swift使用LAContext实现指纹解锁


    通过LAContext的使用,调用系统指纹解锁功能来实现APP的解锁。

    import LocalAuthentication
    
    class ViewController: UIViewController{
       
        var isAvailable:Bool?
        
        @IBOutlet weak var statusLab: UILabel!
        
        override func viewDidLoad() {
            super.viewDidLoad()
    //        laContext = LAContext.init()
    //        //判断touchid在应用中是否可用
    //       var isCanEvaluatePolicy = laContext.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: <#T##NSErrorPointer#>)
        }
       
        @IBAction func checkTouchBtnClick(_ sender: Any) {
           let context = LAContext()
           var error:NSError?
           let isTouchIdAvailable = context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error)
            if isTouchIdAvailable == false{
                statusLab.text = "touch id不能用"
                isAvailable = false
            }else{
                statusLab.text = "touch id能用"
                isAvailable = true;
            }
        }
        @IBAction func authTouchBtnClick(_ sender: Any) {
            if isAvailable != nil && isAvailable == true{
                
                let context = LAContext()
                context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: "请求使用touch id") {[weak self] (bool, error) in
                    if bool{
                        self?.statusLab.text = "通过验证"
                    }else{
                        self?.statusLab.text = "没通过验证"
                    }
                }
                
            }else{
                print("-----------touch id不能用")
            }
        }
    }
    
  • 相关阅读:
    Oracle查看所有表空间使用情况
    Oracle版本信息查看
    Windows 7关闭和开启系统休眠
    ORACLE 创建表空间
    sp_helpdb使用
    SQL SERVER的数据类型
    博客园开通啦
    http keep alive
    android开发学习
    http与html
  • 原文地址:https://www.cnblogs.com/hualuoshuijia/p/12034175.html
Copyright © 2020-2023  润新知