From 9cfae7ab3e9f0d9c4764a5e426ff9b35ae89be85 Mon Sep 17 00:00:00 2001 From: Mattermost Build Date: Sun, 10 Oct 2021 16:42:43 +0200 Subject: [PATCH] Fix send message with physical keyboard on iPad 15 (#5737) (#5738) (cherry picked from commit 16583c2a3b2557684aafc9ac84ac3cc43c47ae1e) Co-authored-by: Elias Nahum --- ios/Mattermost/AppDelegate.m | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/ios/Mattermost/AppDelegate.m b/ios/Mattermost/AppDelegate.m index c6e770f31..001eeaa30 100644 --- a/ios/Mattermost/AppDelegate.m +++ b/ios/Mattermost/AppDelegate.m @@ -146,15 +146,29 @@ NSString* const NOTIFICATION_UPDATE_BADGE_ACTION = @"update_badge"; */ RNHWKeyboardEvent *hwKeyEvent = nil; - (NSMutableArray *)keyCommands { - NSMutableArray *keys = [NSMutableArray new]; if (hwKeyEvent == nil) { hwKeyEvent = [[RNHWKeyboardEvent alloc] init]; } + + NSMutableArray *commands = [NSMutableArray new]; + if ([hwKeyEvent isListening]) { - [keys addObject: [UIKeyCommand keyCommandWithInput:@"\r" modifierFlags:0 action:@selector(sendEnter:)]]; - [keys addObject: [UIKeyCommand keyCommandWithInput:@"\r" modifierFlags:UIKeyModifierShift action:@selector(sendShiftEnter:)]]; + UIKeyCommand *enter = [UIKeyCommand keyCommandWithInput:@"\r" modifierFlags:0 action:@selector(sendEnter:)]; + UIKeyCommand *shiftEnter = [UIKeyCommand keyCommandWithInput:@"\r" modifierFlags:UIKeyModifierShift action:@selector(sendShiftEnter:)]; + if (@available(iOS 13.0, *)) { + [enter setTitle:@"Send message"]; + [shiftEnter setTitle:@"Add new line"]; + } + if (@available(iOS 15.0, *)) { + [enter setWantsPriorityOverSystemBehavior:YES]; + [shiftEnter setWantsPriorityOverSystemBehavior:YES]; + } + + [commands addObject: enter]; + [commands addObject: shiftEnter]; } - return keys; + + return commands; } - (void)sendEnter:(UIKeyCommand *)sender {