// // CommonLocalAuthentication.swift // CommonFrame // // Created by Virgil on 2018/1/15. // Copyright © 2018年 Virgil. All rights reserved. // import UIKit class CommonLocalAuthentication: NSObject { class func localAuthentication() { let context = LAContext() context.localizedFallbackTitle = "*" if #available(iOS 10.0, *) { context.localizedCancelTitle = "取消" } else { // Fallback on earlier versions } var error: NSError? if context.canEvaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, error: &error) { context.evaluatePolicy(.deviceOwnerAuthenticationWithBiometrics, localizedReason: "需要验证您的touch ID", reply: { (success, _) in if success { print("===登录成功====") } else { print("===登录验证失败====") // switch((error as! NSError).code) // { // case kLAErrorSystemCancel: // print("切换到其他APP,系统取消验证Touch ID") // break; // case kLAErrorUserCancel: // print("用户取消验证Touch ID") // break; // default: // break; // } } }) } else { print("===不支持指纹识别====") } } }