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 {