From 5344f2f7c14291fb47342cf1407f6ece3b8b8e90 Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Tue, 4 Oct 2022 10:25:31 -0300 Subject: [PATCH] [FIX] App always using the last deep link on Android (#4585) --- ios/Podfile.lock | 4 +- package.json | 2 +- ...=> react-native-notifications+4.3.1.patch} | 54 ++++++++++++++++++- yarn.lock | 8 +-- 4 files changed, 60 insertions(+), 8 deletions(-) rename patches/{react-native-notifications+4.2.4.patch => react-native-notifications+4.3.1.patch} (55%) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index 0295beaa9..a3e6d2808 100644 --- a/ios/Podfile.lock +++ b/ios/Podfile.lock @@ -370,7 +370,7 @@ PODS: - React-Core - react-native-netinfo (6.0.0): - React-Core - - react-native-notifications (4.2.4): + - react-native-notifications (4.3.1): - React-Core - react-native-orientation-locker (1.1.8): - React @@ -946,7 +946,7 @@ SPEC CHECKSUMS: react-native-jitsi-meet: 3e3ac5d0445091154119f94342efd55c8b1124ce react-native-mmkv-storage: ba38e5e813ea3d5d37af834a9d867b1ce10aa96d react-native-netinfo: e849fc21ca2f4128a5726c801a82fc6f4a6db50d - react-native-notifications: 3de8ef9cd800e5db0225d9aa46b228d2b94ce51e + react-native-notifications: 33ec77006f7987bb22de8f1665889abc633b9196 react-native-orientation-locker: f0ca1a8e5031dab6b74bfb4ab33a17ed2c2fcb0d react-native-restart: 733a51ad137f15b0f8dc34c4082e55af7da00979 react-native-safe-area-context: f0906bf8bc9835ac9a9d3f97e8bde2a997d8da79 diff --git a/package.json b/package.json index f3bb19b6e..abb487fc2 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.3.1", "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.3.1.patch similarity index 55% rename from patches/react-native-notifications+4.2.4.patch rename to patches/react-native-notifications+4.3.1.patch index aa76b2a1e..77c9ca206 100644 --- a/patches/react-native-notifications+4.2.4.patch +++ b/patches/react-native-notifications+4.3.1.patch @@ -13,8 +13,60 @@ index f9c858b..94ea188 100644 public abstract class NotificationManagerCompatFacade { public static NotificationManagerCompat from(@NonNull Context context) { +diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java +index 90969b2..4c00e69 100644 +--- a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java ++++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsModule.java +@@ -63,7 +63,7 @@ public class RNNotificationsModule extends ReactContextBaseJavaModule implements + @Override + public void onNewIntent(Intent intent) { + if (NotificationIntentAdapter.canHandleIntent(intent)) { +- Bundle notificationData = intent.getExtras(); ++ Bundle notificationData = NotificationIntentAdapter.extractPendingNotificationDataFromIntent(intent); + final IPushNotification notification = PushNotification.get(getReactApplicationContext().getApplicationContext(), notificationData); + if (notification != null) { + notification.onOpened(); +diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java +index eadf41e..a3f71dd 100644 +--- a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java ++++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/RNNotificationsPackage.java +@@ -96,8 +96,7 @@ public class RNNotificationsPackage implements ReactPackage, AppLifecycleFacade. + Intent intent = activity.getIntent(); + if (NotificationIntentAdapter.canHandleIntent(intent)) { + Context appContext = mApplication.getApplicationContext(); +- Bundle notificationData = NotificationIntentAdapter.cannotHandleTrampolineActivity(appContext) ? +- NotificationIntentAdapter.extractPendingNotificationDataFromIntent(intent) : intent.getExtras(); ++ Bundle notificationData = NotificationIntentAdapter.extractPendingNotificationDataFromIntent(intent); + final IPushNotification pushNotification = PushNotification.get(appContext, notificationData); + if (pushNotification != null) { + pushNotification.onOpened(); +diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/NotificationIntentAdapter.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/NotificationIntentAdapter.java +index 41b4824..4285ac5 100644 +--- a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/NotificationIntentAdapter.java ++++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/NotificationIntentAdapter.java +@@ -14,17 +14,9 @@ public class NotificationIntentAdapter { + + @SuppressLint("UnspecifiedImmutableFlag") + public static PendingIntent createPendingNotificationIntent(Context appContext, PushNotificationProps notification) { +- if (cannotHandleTrampolineActivity(appContext)) { +- Intent mainActivityIntent = appContext.getPackageManager().getLaunchIntentForPackage(appContext.getPackageName()); +- mainActivityIntent.putExtra(PUSH_NOTIFICATION_EXTRA_NAME, notification.asBundle()); +- TaskStackBuilder taskStackBuilder = TaskStackBuilder.create(appContext); +- taskStackBuilder.addNextIntentWithParentStack(mainActivityIntent); +- return taskStackBuilder.getPendingIntent((int) System.currentTimeMillis(), PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE); +- } else { +- Intent intent = new Intent(appContext, ProxyService.class); +- intent.putExtra(PUSH_NOTIFICATION_EXTRA_NAME, notification.asBundle()); +- return PendingIntent.getService(appContext, (int) System.currentTimeMillis(), intent, PendingIntent.FLAG_ONE_SHOT); +- } ++ Intent intent = appContext.getPackageManager().getLaunchIntentForPackage(appContext.getPackageName()); ++ intent.putExtra(PUSH_NOTIFICATION_EXTRA_NAME, notification.asBundle()); ++ return PendingIntent.getActivity(appContext, (int) System.currentTimeMillis(), intent, PendingIntent.FLAG_UPDATE_CURRENT | PendingIntent.FLAG_ONE_SHOT | PendingIntent.FLAG_IMMUTABLE); + } + + public static boolean cannotHandleTrampolineActivity(Context appContext) { diff --git a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java -index b93f762..c2b736a 100644 +index 54a5fb8..06bbfb9 100644 --- a/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java +++ b/node_modules/react-native-notifications/lib/android/app/src/main/java/com/wix/reactnativenotifications/core/notification/PushNotification.java @@ -28,7 +28,7 @@ public class PushNotification implements IPushNotification { diff --git a/yarn.lock b/yarn.lock index cddaa9ab0..57ac85204 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17212,10 +17212,10 @@ 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: - 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== +react-native-notifications@^4.3.1: + version "4.3.1" + resolved "https://registry.yarnpkg.com/react-native-notifications/-/react-native-notifications-4.3.1.tgz#ad9a8e6881bc17cf03ef16d4dfdaee9ec8bb721d" + integrity sha512-A668d+Q0/VQRjmrh+LvDpc/REA8GXgwCijXDCIlDHGMK8enmrtdxY5OANQf1VM3hecf+fD0wYFw2uqL/ZR8jgg== react-native-notifier@1.6.1: version "1.6.1"