I create my own alert with a touch identifier with the code:
let context = LAContext()
guard deviceCanUseTouchId(context: context) else {
return
}
presentingAlert = true
[context.evaluatePolicy(LAPolicy.DeviceOwnerAuthenticationWithBiometrics, localizedReason: "touch_id_auth_message".localized(), reply: { [unowned self] success, error -> Void in
self.presentingAlert = false
self.canPresentAlert = true
dispatch_async(dispatch_get_main_queue()) {
completionHandler?(success)
}
})]
Button handlercalling the Touch ID native notification is as follows:
@IBAction func touchUpInsideUseTouchIdButton(sender: AnyObject) {
ACTouchId.sharedManager.authenticateWithTouchId(completionHandler: { [weak self] in
self?.handleTouchIdAuthentication(granted: $0)
})
view.endEditing(true)
}
and this is the handleTouchIdAuthentication code:
private func handleTouchIdAuthentication(granted granted: Bool) {
if granted {
} else {
passcodeDigitTextField1.becomeFirstResponder()
}
}
The problem is that most of the time, when I cancel the native Touch ID dialog, the warning turns off correctly, and startFirstResponder () works fine.
However, about 1 time in 10 times, startFirstResponder () returns true, passcodeDigitTextField1 gets focus, but the keyboard does not appear. In addition, the keyboard will not be displayed even if I change focus to another text field by clicking on them.
Strange, this works fine for ios 9 and 8. The problem only happens on iOS 10 .