On an iOS 8 keyboard extension, I have added a UITextField
so the user is enabled to search for emoji or other elements inside the keyboard.
In a case where a user is typing, for instance in the Notes.app, the user taps the search field on the keyboard extension to start searching. When tapped, the extension logs:
-[UIKeyboardInputManagerClient handleError:forRequest:] will retry sending syncToKeyboardState:completionHandler: to keyboard daemon after receiving Error Domain=NSCocoaErrorDomain Code=4099 "The operation couldn’t be completed. (Cocoa error 4099.)" (The connection to service named com.apple.TextInput was invalidated.) UserInfo=0x170276e00 {NSDebugDescription=The connection to service named com.apple.TextInput was invalidated.}
Please check for kbd crash logs. -[UIKeyboardInputManagerClient handleError:forRequest:] closed connection to keyboard daemon after two consecutive failures sending
After this, the user taps on the Notes.app text to go back to editing it. Now any text sent to the textDocumentProxy using insertText:
still goes to my keyboard extensions UITextField
instead of the Notes.app text.
The textDidChange:
delegate method is still called from the Notes text when tapping it. Also, the textDocumentProxys properties documentContextBeforeInput
and documentContextAfterInput
contain the correct text from the Notes.app text.
It looks like the UITextField
is now a "listener" for the textDocumentProxy, which it should not be.
I have tried, without success:
- setting
userInteractionEnabled = NO
on theUITextField
resignFirstResponder
on theUITextField
endEditing:YES
on theUITextField
- monitoring the
textDocumentProxy
property for changes but it keeps referencing the same object.
A workaround is selecting another keyboard and then going back to my keyboard. Then the connection is restored and everything goes back to normal. (Until the user taps on my UITextField again).
In the App Store I have found several custom keyboard apps that have the same problem. This lead me to think it is unsolvable. However, I have also found custom keyboard apps which work fine and the user can jump around the text fields without problems.
Any ideas?