From 9c0f70b92e3f8bfdb259b5f9b645cac2331c201d Mon Sep 17 00:00:00 2001 From: Diego Mello Date: Fri, 4 Nov 2022 13:33:03 -0300 Subject: [PATCH] [FIX] Push notification's deep linking not working when opened from a cold state on Android (#4648) --- ios/Podfile.lock | 4 +-- package.json | 2 +- ...=> react-native-notifications+4.3.2.patch} | 26 +++++++++++++++++-- yarn.lock | 8 +++--- 4 files changed, 31 insertions(+), 9 deletions(-) rename patches/{react-native-notifications+4.3.1.patch => react-native-notifications+4.3.2.patch} (89%) diff --git a/ios/Podfile.lock b/ios/Podfile.lock index e7a305b20..c7fa41434 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.3.1): + - react-native-notifications (4.3.2): - 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: 33ec77006f7987bb22de8f1665889abc633b9196 + react-native-notifications: f3215821dfd74234f8f3910e2fe37e19fa8673b0 react-native-orientation-locker: f0ca1a8e5031dab6b74bfb4ab33a17ed2c2fcb0d react-native-restart: 733a51ad137f15b0f8dc34c4082e55af7da00979 react-native-safe-area-context: f0906bf8bc9835ac9a9d3f97e8bde2a997d8da79 diff --git a/package.json b/package.json index 491965054..8c1a7ed62 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.3.1", + "react-native-notifications": "^4.3.2", "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.3.1.patch b/patches/react-native-notifications+4.3.2.patch similarity index 89% rename from patches/react-native-notifications+4.3.1.patch rename to patches/react-native-notifications+4.3.2.patch index 77c9ca206..591f491fc 100644 --- a/patches/react-native-notifications+4.3.1.patch +++ b/patches/react-native-notifications+4.3.2.patch @@ -27,10 +27,32 @@ index 90969b2..4c00e69 100644 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 +index c090247..494aae8 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. +@@ -20,6 +20,7 @@ import com.wix.reactnativenotifications.core.notification.PushNotification; + import com.wix.reactnativenotifications.core.notification.PushNotificationProps; + import com.wix.reactnativenotifications.core.notificationdrawer.IPushNotificationsDrawer; + import com.wix.reactnativenotifications.core.notificationdrawer.PushNotificationsDrawer; ++import com.wix.reactnativenotifications.core.ReactAppLifecycleFacade; + + import java.util.Arrays; + import java.util.Collections; +@@ -67,7 +68,12 @@ public class RNNotificationsPackage implements ReactPackage, AppLifecycleFacade. + + @Override + public void onActivityStarted(Activity activity) { +- if (InitialNotificationHolder.getInstance().get() != null) { ++ boolean isReactInitialized = false; ++ if (AppLifecycleFacadeHolder.get() instanceof ReactAppLifecycleFacade) { ++ isReactInitialized = AppLifecycleFacadeHolder.get().isReactInitialized(); ++ } ++ ++ if (InitialNotificationHolder.getInstance().get() == null && !isReactInitialized) { + callOnOpenedIfNeed(activity); + } + } +@@ -96,8 +102,7 @@ public class RNNotificationsPackage implements ReactPackage, AppLifecycleFacade. Intent intent = activity.getIntent(); if (NotificationIntentAdapter.canHandleIntent(intent)) { Context appContext = mApplication.getApplicationContext(); diff --git a/yarn.lock b/yarn.lock index 59fc00f8f..8c1b12e98 100644 --- a/yarn.lock +++ b/yarn.lock @@ -17221,10 +17221,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.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-notifications@^4.3.2: + version "4.3.2" + resolved "https://registry.yarnpkg.com/react-native-notifications/-/react-native-notifications-4.3.2.tgz#43b5fa6b2dbd49e38eadca8b8d102394a9ac7929" + integrity sha512-QGzlO9ON2nyk1G8y1JIwv9kqpu8OQYSmqsmSzl/rXtXwCWx/WDFNb5rkBtAZQKuebtK2/Vczhfk4khraRmJj0Q== react-native-notifier@1.6.1: version "1.6.1"