How can I tell which third party keyboard the user is using or switching to?
I did not find any notification or API that I could use to check this info.
How can I tell which third party keyboard the user is using or switching to?
I did not find any notification or API that I could use to check this info.
You can't know which keyboards are installed, nor can you decide which keyboard to load next.
Apple's documentation states:
To ask the system to switch to another keyboard, call the advanceToNextInputMode method (..) The system picks the appropriate “next” keyboard; there is no API to obtain a list of enabled keyboards or for picking a particular keyboard to switch to.
For further information, read Apple's Custom Keyboards API Documentation: https://developer.apple.com/library/ios/documentation/General/Conceptual/ExtensibilityPG/Keyboard.html#//apple_ref/doc/uid/TP40014214-CH16-SW21
A bit late but you can get the list of active keyboards on a device. All keyboard identifiers are stored in UserDefaults
and here is how you can get them:
/**
- Author:
Panayot Panayotov
- returns:
True or False
- Important:
Result is returned immediately after non system identifier is found
This method iterates through all public keyboard identifiers and
evaluates a regex that matches system keyboards
[
"nb_NO@sw=QWERTY-Norwegian;hw=Automatic",
"zh_Hant-Zhuyin@sw=Zhuyin;hw=Automatic",
"ur@sw=Urdu;hw=Automatic",
"zh_Hant-HWR@sw=HWR-Traditional",
"zh_Hant-Pinyin@sw=Pinyin10-Traditional;hw=Automatic",
"emoji@sw=Emoji"
]
*/
-(BOOL)hasUnkownKeyboard {
NSString * appleKeyboardsRegexp = @"^(?:[0-9a-zA-Z_\\-]+)(?:@sw|@hw)[0-9a-zA-Z_\\-\\-;=]*$";
NSPredicate * appleKeyboardsTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", appleKeyboardsRegexp];
NSArray *keyboards = [[[NSUserDefaults standardUserDefaults] dictionaryRepresentation] objectForKey:@"AppleKeyboards"];
for (NSString *keyboard in keyboards) {
if(![appleKeyboardsTest evaluateWithObject:keyboard]){
return YES;
}
}
return NO;
}