ios icon indicating copy to clipboard operation
ios copied to clipboard

Conflict with react native firebase getInitialNotification method

Open chahinaghrim opened this issue 5 years ago • 2 comments

Question

Currently, I am using push-notifications-ios to listen for remote notifications and update the badge count of the app outside and inside the app when the app is in the foreground and in the background. My main goal is to update the bagde count for iOS.

I am also using firebase notifications to listen for new notifications. Currently when getting a new notification , I am initialising getInitialNotification() from firebase to extract the notification and to navigate the user to the correct screen. This only works on android as I do not register my device using PushNotificationsIOS. On iOS, when opening a notification when the app was fully closed, it will redirect me to the home screen of the app and never to the desired screen.

I do not know why I am not able to extract the notification with getInitialNotification() when my device is registered with PushNotificationIOS.

Can you please help me?

MY ENVIRONMENT System: OS: macOS 10.15.3 CPU: (4) x64 Intel(R) Core(TM) i5-5257U CPU @ 2.70GHz Memory: 104.25 MB / 8.00 GB Shell: 5.7.1 - /bin/zsh Binaries: Node: 12.13.1 - ~/.nvm/versions/node/v12.13.1/bin/node Yarn: 1.22.4 - ~/Documents/youpendo-app-bareworkflow/node_modules/.bin/yarn npm: 6.12.1 - ~/.nvm/versions/node/v12.13.1/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.9.3 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 13.2, DriverKit 19.0, macOS 10.15, tvOS 13.2, watchOS 6.1 Android SDK: API Levels: 28, 29 Build Tools: 28.0.3, 29.0.2 System Images: android-28 | Google APIs Intel x86 Atom, android-29 | Google APIs Intel x86 Atom Android NDK: Not Found IDEs: Android Studio: 3.6 AI-192.7142.36.36.6392135 Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild Languages: Java: 1.8.0_232 - /usr/bin/javac Python: 2.7.16 - /usr/bin/python npmPackages: @react-native-community/cli: ^4.8.0 => 4.10.0 react: 16.11.0 => 16.11.0 react-native: 0.62.2 => 0.62.2 react-native-bootsplash version: "^2.2.5". Platform: Ios Device: iPhone 8 Simulator: no

chahinaghrim avatar Aug 14 '20 10:08 chahinaghrim

I am facing the same issue. Any solution?

ghasemikasra39 avatar Aug 21 '20 12:08 ghasemikasra39

This could potentially be because of #24 If you are running development with Debug JS enabled, the RCTBridge used does not actually have the remote notification in the launchOptions, so it will always return null.

Disable Debug JS and you can log out to metro to see the notification is then returned.

Not a great developer experience, maybe someone could open a PR to use UIApplication.shared.delegate as suggested in the other issue

Also note that getInitialNotification is only for grabbing the notification from cold boot after user interaction or remote notification received whilst killed, it won't return a notification if your app is already running, (background or foreground).

raldred avatar Jan 16 '21 15:01 raldred