Initial setup of the keyboard.
Interface for calling all functions regarding the KeyboardViewController.
- (void) subscribeEventBus:(NSArray*) arrayEvents;
Call this method to subscribe to all the events you want to observe. Possible subscribable events are defined in FleksyDefines.h file.
@Int type (ButtonType specified in FKEnums.h file) @string letter for NOTIFICATION_KEY_PRESSED. Here are the most used:
type: @Array of @Int for NOTIFICATION_KEY_NEW_NWP (Specified in FKEnums.h file). Here are the values:
- (void) reloadSettings;
Method to reload settings configuration. It currently reloads the “by default settings”, although it does not reload the themes. Specifically, for reloading the themes call the next function.
- (bool) reloadTheme:(NSDictionary*) theme;
Call this method with the theme passed as dict in Json format to immediately reload the current theme.
If the system was not able to reload the theme, it will return false. This can happen when swiping and reloading the theme at the same time.
let dictTheme: [String : Any] = [
- (void) reloadConfiguration:(EmojiConfiguration*) configuration;
Function to reload emoji configuration, via EmojiConfiguration, which changes the current emoji skin tones.
- (void) insertText:(NSString*) text;
Call this method with text as parameter to insert it after the cursor position.
- (void) replaceText:(NSString*) text inRange:(NSRange) range;
Call this method for replacing text at position location and length.
- (void) replaceAllTextWith:(NSString*) text;
Call this method for replacing all the current text with the new one as argument.
- (void) deleteBackward;
Call this to delete one character from the current cursor position.
- (void) deleteBackwardWord;
Call this to delete the last word (or half word) from the current cursor position.
- (void) insertWordPrediction:(NSString*) prediction withType:(WordPredictionType) type;
Call this method to insert a word prediction to the current text field.
This is useful if you have customised the top bar and you receive predictions sent by the core, which displays in your custom topbar. When the end-user presses the prediction, call this method to insert the prediction in the textfield.
(void) updateKeyboardInsets:(UIEdgeInsets) insets;
Call this method if you want to change the insets of the keyboard on the fly. It modifies the position of the keys accordingly to the UIEdgeInsets pass as parameter.
UIEdgeInsets insets = UIEdgeInsetsMake(0,10,0,10)
End result would be a keyboard 10 points to the right and 10 to the left, reducing the total width in 20 points.
- (void) addCustomActions:(NSDictionary*) dict;
This function will be deprecated, the recommendation is not to use it.
- (void) addWordUserDictionary:(NSString*) word;
Function to add a word to the user dictionary. The SDK automatically adds/remove words from the user dictionary depending on the learning status on the Engine side. However, this allows the client to interact with the dictionary to add specific words.
- (NSArray*) listWordUserDictionary;
Function to retrieve all words in the user dictionary.
It returns a list of NSString ordered from A-Z. If there are no words in the dictionary, it returns an empty array.
- (void) removeWordUserDictionary:(NSString*) word;
Function to delete a specific word from the user dictionary.
- (void) removeAllWordsUserDictionary;
Function to delete all user dictionary words. It deletes all words learned by the user.
- (void) deleteAutolearnDictionary;
Function to delete all automatically learned words.
This is mostly intended to be used when we test the keyboard, or when the user wants to remove all information. As normal practice, it is good to enable the autolearn and not to remove this dictionary. (Internally we manage this properly to avoid the need for a big dictionary)
- (void) updateFlaggedWordsFile:(NSString*) filePath forLanguage:(NSString*) language;
Call this method with the filepath and the language that we want to use for flagged words. After calling this method, the next time the Keyboard opens up this list of flagged words will be loaded.
NSURL* directoryURL = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:<group>];
directoryURL = [[NSFileManager defaultManager] temporaryDirectory];
NSString* fileName = [NSString stringWithFormat:@"%@/flaggedWords.txt", directoryURL.path];
NSString* content = @"thisword\nanotherword\n";
[content writeToFile:fileName atomically:YES encoding:NSUTF8StringEncoding error:nil];
[self.interface updateFlaggedWordsFile:fileName forLanguage:@"en-US"];
If something needs to be added or if you find an error in our documentation, please let us know either on our GitHub or Discord.
Last updated on June 18, 2023