iOS[swift] 指紋驗證功能模塊

iOS調用TouchID代碼:

    override func viewDidLoad() {
        super.viewDidLoad()
        let context = LAContext()
        var error: NSError? = nil
        let canEvaluatePolicy = context.canEvaluatePolicy(LAPolicy.deviceOwnerAuthenticationWithBiometrics, error: &error) as Bool
        if error != nil {
            print(error!.localizedDescription as String)
        }
        
        if canEvaluatePolicy {
            print("有指紋驗證功能")
            context.evaluatePolicy(LAPolicy.deviceOwnerAuthenticationWithBiometrics, localizedReason: "放上您的狗爪", reply: { (success: Bool, error: Error?) in
                if success {
                    print("驗證成功")
                } else {
                    print("驗證失敗: \(error?.localizedDescription)")
                }
            })
        } else {
            print("還沒開啟指紋驗證呢")
        }
    }
最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容