When a bluetooth keyboard is linked to an iPhone and being used, the virtual keyboard is hidden. How can I disable this behaviour?
My app is built using React Native Expo and requires access to the soft keyboard and physical bluetooth keyboard simultaniously as functions need to be triggered remotely. However when the bluetooth keyboard is connected the virtual keyboard hides off screen until the keyboard is disconnected.
I’m aware that some keyboards have a shortcut for bringing the keyboard back up, but this isn’t a solution for me sadly- I need to find a way to prevent the keyboard from hiding at all.
I’ve been playing with the native ios folder and Objective C files to see if there’s a way to hard code this functionality, following various threads on SO but no success yet. I’m not familiar with the native code at all but I’m confident what I want can’t be achieved in JSX. I will be looking for a solution on android too but I’m focusing on getting iOS working first.
With the number of posts around this topic over the years already, someone must have found a solution?
Any points in the right direction or tips on tackling the native code would be appreciated.
Thank you.
Here is one of the things I tried in AppDelegate.mm already:
added these lines to AppDelegate.mm:
#import <React/RCTRootView.h>
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textFieldBegan:) name:UITextFieldTextDidBeginEditingNotification object:nil];
- (void)textFieldBegan:(NSNotification *)theNotification {
UITextField *theTextField = [theNotification object];
if (!inputAccessoryView) {
inputAccessoryView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, 1)];
}
theTextField.inputAccessoryView = inputAccessoryView;
[self performSelector:@selector(forceKeyboard) withObject:nil afterDelay:0];
}
- (void)forceKeyboard {
inputAccessoryView.superview.frame = CGRectMake(0, [UIScreen mainScreen].bounds.size.height - 265, [UIScreen mainScreen].bounds.size.width, 265);
}```
```- (BOOL)application:(UIApplication *)application shouldAllowExtensionPointIdentifier:(UIApplicationExtensionPointIdentifier)extensionPointIdentifier {
if ([extensionPointIdentifier isEqualToString:UIApplicationKeyboardExtensionPointIdentifier]) {
return NO;
}
return YES;
}```
//Then rebuilt the project. No change in keyboard behaviour.