-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
[馃悰] 馃敟 @react-native-firebase/messaging (Android) - Messaging() gets the wrong ReactContext when there is another Activity instantiated by ReactInstanceManager? #7768
Comments
If you need me to provide more information, feel free to ask me @mikehardy |
Hey there - two thoughts, 1- can you use current versions please, just to make sure we're not chasing ghosts?
|
For troubleshooting:
What makes you think that? I suggest using System.out.println or similar in the native code (yours and you can add it easily to react-native-firebase/messaging) to log out exactly what context is in use to see if they are different and/or incorrect. In general it sounds like inference on a problem but without direct proof, and direct proof / ability to fix + test fixes will be difficult in the context of a large app whereas a https://stackoverflow.com/help/minimal-reproducible-example that was purpose built to expose the issue in could make it trivial to spot + verify fix |
I think so because if I copy notificationHandler's code and use in Bubble code, messages() works properly in Bubble code MainApp uses index.js entry file, Bubble uses index2.js entry file, each file leads to its own folder in the source code Edit: I put Log in onReceive inside ReactNativeFirebaseMessagingReceiver.java, it is the same context. But I don't know why messaging() code only runs in Bubble Code after opening the Bubble screen. If I close Bubble and close the app in recent apps. Then use it normally without open Bubble it works normally |
my bad, thanks for your reply. I just updated all React-native-firebase to the latest version (19.2.2). But the result is still the same. |
I updated BubbleActivity in AndroidManifest, when I open MainApp without closing Bubble, it looks like messaging() "thinks" MainApp is not in foreground |
In general it sounds like inference on a problem but without direct proof, and direct proof / ability to fix + test fixes will be difficult in the context of a large app whereas a https://stackoverflow.com/help/minimal-reproducible-example that was purpose built to expose the issue in could make it trivial to spot + verify fix |
Hi there, |
if you have any confusion, please tell me @mikehardy |
Same issue :( |
Issue
Hello, first of all, thank you for the wonderful library.
In my app chat. I have an "Bubble Chat" which uses Bubbles API. It will show Bubbles when it receives new notifications.
And when you press on the bubble, then will display a window that runs startReactApplication display conversation screen (like Messenger).
The problem is that after pressing the Bubble, messaging() function in my Main App code doesn't works anymore, but if I use these codes in Bubble Chat code (separate from MainApp code) it still works. But if i delete Main App from Recent Apps, then reopen, from now on it work fine until I press a new bubble => start new conversation screen. (Ah sh*t, here we go again) => So i think when a react app start, this lib will use the most recent ReactContext of the app that just started.
Since messaging() in Main App was not working, it caused all my messaging().onNotificationOpenedApp, messaging().onMessage, messaging().getInitialNotification() to not working anymore
Thanks for helping me
i will provide some code here:
Project Files
BubbleActivity.kt:
And this is now in MainApp, where i use messaging() for handle notification
NotificationHandler.tsx
Then i used it like a component in MainApp
###App.tsx
package.json
:Android
Click To Expand
Have you converted to AndroidX?
android/gradle.settings
jetifier=true
for Android compatibility?jetifier
for react-native compatibility?android/build.gradle
:android/app/build.gradle
:android/settings.gradle
:MainApplication.java
:AndroidManifest.xml
:Environment
Click To Expand
react-native info
output:The text was updated successfully, but these errors were encountered: