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("還沒開啟指紋驗證呢")
}
}