I'm creating an native touch id alert with 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 handler that calls the native Touch ID alert looks like this:
@IBAction func touchUpInsideUseTouchIdButton(sender: AnyObject) {
ACTouchId.sharedManager.authenticateWithTouchId(completionHandler: { [weak self] in
self?.handleTouchIdAuthentication(granted: $0)
})
view.endEditing(true)
}
and this is the code of handleTouchIdAuthentication:
private func handleTouchIdAuthentication(granted granted: Bool) {
if granted {
//...
} else {
passcodeDigitTextField1.becomeFirstResponder()
}
}
The problem is, that most of the time, when I cancel the Touch ID native dialog, the alert dismiss correctly and becomeFirstResponder() works OK.
However at around 1 in 10 times, becomeFirstResponder() returns true, passcodeDigitTextField1 gets focus, but the keyboard does not appear. Moreover keyboard will not show itself even if I change the focus to other text field by tapping them.
Strangly, this works fine for ios 9 and 8. The issue happens only on iOS 10.