iOS开发 - 手机指纹验证

手机指纹验证

iOS开发 - 手机指纹验证_第1张图片
指纹验证
import LocalAuthentication
struct Validation {
    /**
     *LAPolicyDeviceOwnerAuthentication 手机密码的验证方式
     *LAPolicyDeviceOwnerAuthenticationWithBiometrics 指纹的验证方式
     */
    static func fingerprint(callBack:(isSuccess: Bool?) -> ()) {
        let context = LAContext()
        let can = context.canEvaluatePolicy(.DeviceOwnerAuthentication, error: nil)
        guard can  == true else {
            callBack(isSuccess: nil)
            return   //不可用
        }
        context.evaluatePolicy(.DeviceOwnerAuthentication, localizedReason: "打个卡") { (success, error) in
            callBack(isSuccess: success)
        }
    }
}

使用

        Validation.fingerprint{ (isSuccess) in
            print(isSuccess) // true 成功  false 失败 nil 不可用
        }

你可能感兴趣的:(iOS开发 - 手机指纹验证)