0
私は現在自分のアプリでtouchIDを持っており、現在正しく動作しています。あなたがログインするたびに、「touchID activated」警告がポップアップするたびにちょっと迷惑です。それを変更する方法はありますか?最初にログインするだけで、もう一度は表示されません。ここではタッチIDのための私のコードは、私は、ログイン画面の中のviewDidLoad checkIfTouchIDActivated()を呼び出す:アプリにログインするたびに「touch ID activated」アラートを無効にするにはどうすればよいですか?
// MARK: TouchID
//Create a authentication context
let authenticationContext = LAContext()
var error:NSError?
//Check if the device has a fingerprint sensor, if not, dismiss
func checkIfTouchIDActivated() {
guard authenticationContext.canEvaluatePolicy(.DeviceOwnerAuthenticationWithBiometrics, error: &error) else {
print("TouchID not detected")
return
}
print("TouchID detected")
//Check the fingerprint
authenticationContext.evaluatePolicy(
.DeviceOwnerAuthenticationWithBiometrics,
localizedReason: "TouchID activated",
reply: { [unowned self] (success, error) -> Void in
//fingerprint has been recognized
if(success){
self.loginButtonPressed(self)
}else {
// Check if there is an error
if let error = error {
let message = self.touchID.errorMessageForLAErrorCode(error.code)
self.showAlertViewAfterEvaluatingPolicyWithMessage(message)
}
}
})
}