diff --git a/e2e/tests/assorted/11-deeplinking.spec.ts b/e2e/tests/assorted/11-deeplinking.spec.ts index 4b9de7772..5a7450359 100644 --- a/e2e/tests/assorted/11-deeplinking.spec.ts +++ b/e2e/tests/assorted/11-deeplinking.spec.ts @@ -1,3 +1,5 @@ +import EJSON from 'ejson'; + import data from '../../data'; import { tapBack, checkServer, navigateToRegister, platformTypes, TTextMatcher } from '../../helpers/app'; import { get, login, sendMessage } from '../../helpers/data_setup'; @@ -141,6 +143,41 @@ describe('Deep linking', () => { .toBeVisible() .withTimeout(2000); }); + + it('should simulate a tap on a push notification and navigate to the room', async () => { + /** + * Ideally, we would repeat this test to simulate a resume from background, + * but for some reason it was not working as expected + * This was always turning to false right before running the logic https://github.com/RocketChat/Rocket.Chat.ReactNative/blob/18f359a8ef9691144970c0c1fad990f82096b024/app/lib/notifications/push.ts#L58 + */ + // await device.sendToHome(); + await device.launchApp({ + newInstance: true, + userNotification: { + trigger: { + type: 'push' + }, + title: 'From push', + body: 'Body', + badge: 1, + payload: { + ejson: EJSON.stringify({ + rid: null, + host: data.server, + name: data.groups.private.name, + type: 'p' + }) + } + } + }); + await waitFor(element(by.id(`room-view-title-${data.groups.private.name}`))) + .toExist() + .withTimeout(30000); + await tapBack(); + await waitFor(element(by.id('rooms-list-view'))) + .toBeVisible() + .withTimeout(2000); + }); }); describe('Others', () => { diff --git a/ios/RocketChatRN/AppDelegate.h b/ios/RocketChatRN/AppDelegate.h index 2ea45993e..8d328571a 100644 --- a/ios/RocketChatRN/AppDelegate.h +++ b/ios/RocketChatRN/AppDelegate.h @@ -10,6 +10,9 @@ #import #import #import +// https://github.com/expo/expo/issues/17705#issuecomment-1196251146 +#import "ExpoModulesCore-Swift.h" +#import "RocketChatRN-Swift.h" @interface AppDelegate : EXAppDelegateWrapper diff --git a/ios/RocketChatRN/AppDelegate.mm b/ios/RocketChatRN/AppDelegate.mm index d647af0e8..76f069866 100644 --- a/ios/RocketChatRN/AppDelegate.mm +++ b/ios/RocketChatRN/AppDelegate.mm @@ -46,7 +46,6 @@ } [Bugsnag start]; - // UIView *rootView = RCTAppSetupDefaultRootView(bridge, @"RocketChatRN", nil); UIView *rootView = [self.reactDelegate createRootViewWithBridge:bridge moduleName:@"RocketChatRN" initialProperties:nil]; if (@available(iOS 13.0, *)) { @@ -60,7 +59,9 @@ rootViewController.view = rootView; self.window.rootViewController = rootViewController; [self.window makeKeyAndVisible]; - [super application:application didFinishLaunchingWithOptions:launchOptions]; + [RNNotifications startMonitorNotifications]; + [ReplyNotification configure]; + // AppGroup MMKV NSString *groupDir = [[NSFileManager defaultManager] containerURLForSecurityApplicationGroupIdentifier:[[NSBundle mainBundle] objectForInfoDictionaryKey:@"AppGroup"]].path; [MMKV initializeMMKV:nil groupDir:groupDir logLevel:MMKVLogNone]; diff --git a/package.json b/package.json index 68dcd5352..7aa2df744 100644 --- a/package.json +++ b/package.json @@ -104,7 +104,7 @@ "react-native-mmkv-storage": "^0.7.6", "react-native-modal": "13.0.1", "react-native-navigation-bar-color": "2.0.1", - "react-native-notifications": "^4.2.4", + "react-native-notifications": "4.2.4", "react-native-notifier": "1.6.1", "react-native-orientation-locker": "1.1.8", "react-native-picker-select": "^8.0.4", diff --git a/patches/react-native-notifications+4.2.4.patch b/patches/react-native-notifications+4.2.4.patch index 90172f836..aa76b2a1e 100644 --- a/patches/react-native-notifications+4.2.4.patch +++ b/patches/react-native-notifications+4.2.4.patch @@ -41,3 +41,61 @@ index f9c858b..94ea188 100644 public abstract class NotificationManagerCompatFacade { public static NotificationManagerCompat from(@NonNull Context context) { +diff --git a/node_modules/react-native-notifications/lib/ios/RCTConvert+RNNotifications.h b/node_modules/react-native-notifications/lib/ios/RCTConvert+RNNotifications.h +index 8b2c269..8667351 100644 +--- a/node_modules/react-native-notifications/lib/ios/RCTConvert+RNNotifications.h ++++ b/node_modules/react-native-notifications/lib/ios/RCTConvert+RNNotifications.h +@@ -1,5 +1,5 @@ + #import +-@import UserNotifications; ++#import + + @interface RCTConvert (UIMutableUserNotificationAction) + + (UIMutableUserNotificationAction *)UIMutableUserNotificationAction:(id)json; +diff --git a/node_modules/react-native-notifications/lib/ios/RNNotificationCenter.h b/node_modules/react-native-notifications/lib/ios/RNNotificationCenter.h +index 4bc5292..4839d55 100644 +--- a/node_modules/react-native-notifications/lib/ios/RNNotificationCenter.h ++++ b/node_modules/react-native-notifications/lib/ios/RNNotificationCenter.h +@@ -4,7 +4,7 @@ typedef void (^RCTPromiseResolveBlock)(id result); + typedef void (^RCTResponseSenderBlock)(NSArray *response); + typedef void (^RCTPromiseRejectBlock)(NSString *code, NSString *message, NSError *error); + +-@import UserNotifications; ++#import + + @interface RNNotificationCenter : NSObject + +diff --git a/node_modules/react-native-notifications/lib/ios/RNNotificationEventHandler.h b/node_modules/react-native-notifications/lib/ios/RNNotificationEventHandler.h +index a07c6e9..8e3ca6a 100644 +--- a/node_modules/react-native-notifications/lib/ios/RNNotificationEventHandler.h ++++ b/node_modules/react-native-notifications/lib/ios/RNNotificationEventHandler.h +@@ -1,5 +1,5 @@ + #import +-@import UserNotifications; ++#import + #import "RNNotificationsStore.h" + #import "RNEventEmitter.h" + +diff --git a/node_modules/react-native-notifications/lib/ios/RNNotificationParser.h b/node_modules/react-native-notifications/lib/ios/RNNotificationParser.h +index 7aa2bfb..c1c019c 100644 +--- a/node_modules/react-native-notifications/lib/ios/RNNotificationParser.h ++++ b/node_modules/react-native-notifications/lib/ios/RNNotificationParser.h +@@ -1,5 +1,5 @@ + #import +-@import UserNotifications; ++#import + + @interface RNNotificationParser : NSObject + +diff --git a/node_modules/react-native-notifications/lib/ios/RNNotificationsStore.h b/node_modules/react-native-notifications/lib/ios/RNNotificationsStore.h +index 4f8a171..7e4f9ca 100644 +--- a/node_modules/react-native-notifications/lib/ios/RNNotificationsStore.h ++++ b/node_modules/react-native-notifications/lib/ios/RNNotificationsStore.h +@@ -1,6 +1,6 @@ + #import + #import +-@import UserNotifications; ++#import + + @interface RNNotificationsStore : NSObject + diff --git a/yarn.lock b/yarn.lock index 3c9ce6be4..cddaa9ab0 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17212,7 +17212,7 @@ react-native-navigation-bar-color@2.0.1: resolved "https://registry.yarnpkg.com/react-native-navigation-bar-color/-/react-native-navigation-bar-color-2.0.1.tgz#ee2be25cc37105f7da355717b0a9a32c9c059ae6" integrity sha512-1kE/oxWt+HYjRxdZdvke9tJ365xaee5n3+euOQA1En8zQuSbOxiE4SYEGM7TeaWnmLJ0l37mRnPHaB2H4mGh0A== -react-native-notifications@^4.2.4: +react-native-notifications@4.2.4: version "4.2.4" resolved "https://registry.yarnpkg.com/react-native-notifications/-/react-native-notifications-4.2.4.tgz#0d686eb1576d3d9cb73dd9db1ee4f212e00f7d89" integrity sha512-ffToxERa2bRUsXShCO19yXY6c6l4Esq7MqRKAb4mPSn+T428X7Je7WYvWOIOVw/BMGJ3R0lPrZk52vDpoYqanw==