-
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
🔥v6 onMessage is not fire when app in foreground #3040
Comments
the same thing happened to me as well, I think the notification module is not published yet by them. |
i think if notification module is not published (they publish different package is Notifee but not OSS), so all message from firebase should be fire to onMessage event |
After testing i confirm the event |
"someone" is us. It's open source Pull Requests happily accepted |
@mikehardy i want to help but i don't know about native code. Can you add |
The same thing happen to me. Data and Push notification received when in background. When in Foreground Push notification doesn't work, but still can receive data (using onMessage) |
In foreground, notification won't be shown. You need push notification manual. |
I tested on Android Emulator Hope |
@maitrungduc1410 not going to happen - notifications is not a firebase core service (from google) so it won't exist going forward. Use data-only messages and a local solution (like react-native-push-notifications) as you've done |
|
RNFBv6 does not do notifications-anything. So a notification-only payload has no relation to react-native-firebase v6 and nothing should happen. Seems expected |
can we use RNFBv6 to receive notification only FCM and show the notification ourself? |
@kukuhyoniatmoko In my opinion you should use RNFBv6 to receive data-only FCM, then react-native-push-notification or similar to show the notification yourself. If you use notification payload or mixed data+notification payload, sometimes the firebase SDKs automatically do notification stuff (background, killed) sometimes you have to do it (foreground), which to me makes things hard to reason through. But it's should be possible to do notification-only + react-native-push-notifications and get all the cases handled well as well. |
Yes, on android firebase SDK we can receive notification only payload and then handle that ourself if fourground. So, I kind of expecting the same behavior on RNFBv6 |
@mikehardy thanks for your work on this. I've scoured this repo for an answer and you've been very helpful. My argument for all notifications being received by onMessage is that I need to conditionally show notifications based on whether the app is in the foreground/killed (example, a chat app. you want notifications for new messages but not while you're in the app) Looks like i'm going to have two requests per notification per chat message, (one to determine if app is closed and one to send the actual notification) which is not ideal but may work. |
We don't do anything here, if you send an FCM payload with a I've also got |
@Ehesp: As above my comment, on IOS onMessage event does not working in the foreground on v6. Should we fix this? |
I've tested push both on background and foreground with iOS and Android and everything works. To make it work on iOS foreground I had to sent the push through APNs as a silent notification and not through the FCM connection server. I hope it is useful. |
i think the onMessage should be fire not only silent notification but also mix payload |
This is really frustrating/confusing for me. The documentation suggests that onMessage should fire when either in the foreground or background, but neither case works. There's also nothing in the documentation suggesting to modify AppDelegate.m to handle remote notifications. I'd really appreciate some clarity for a newbie - most of the suggestions here are way over my head.
I should also clarify that I'm trying to send messages from the FCM dashboard. Something on the old RNFB site suggests that the console can only send notifications, which is handled by a separate notification library and that the data-only notifications that onMessage receives only data-only messages, which cannot be sent by the firebase console anyway, only through cloud functions/etc. So this adds confusion to the mix. For the time being I think I'm going to switch over to 5.x because that worked without this stress. |
Running on IOS 13.3. For me sent from the console. The notification shows without hitting the messaging().setBackgroundMessageHandler();. |
I have an example app locally with it working in both situations. We're overhauling the docs and messaging will be getting my main focus #3217. @tmaly1980 your frustrations are welcome! Honestly, there is a LOT going on with messaging under the hood and it's confusing to us too. Hopefully in the next few weeks we'll have some more docs with full guides in place. |
I just want to ask in v6 the event (listener) "notification when open" is this been removed? if I click the FCM message on my notification bar, it will not receive any data for that notification? I'm so confused on the cloud messaging Thanks, UPDATEDI just installed the react-native-push-notification , this solves my issue from background notification. Also, I notice on iOS the only thing you can test the FCM is through actual device with RELEASE version built. It will not work in DEBUG version of the app and it gives me an error even I'm using an actual device (not via simulator). |
any updates? |
Does onMessage work in previous versions? |
Yes, v5 works like a charm. |
@Ehesp |
Just a heads up, myself and @Salakar just spent the entire day digging into the depths of Android FCM. We're going to release an update to v6 at some point (will link PR when it's up), however in a nutshell this will be the update:
It's worth noting that a visible notification will only be displayed on the device when the apps is quit or in the background. This is controlled fully by Android. If you wish to display one in the Foreground, or anything other than a title/body/image, you need to use a 3rd party library. iOS will be getting reviewed next to figure out these things. |
Okay so Android seems to be working (needs more testing etc), so I'll move onto iOS next. |
Hello @Ehesp will you be able to tell us a date where the version 7 would be released? We are waiting to have this since we have upgraded Crashlytics to v6, unfortunately, all our firbase notification breaks since we have been using version 5 for that. we also have the same problems of having v6 for notifications :( |
Android updates are in 6.4.0-rc0 which you can try out now. I'm currently working on ios changes to match. |
Perfects and thanks, maybe a rough date of ios release :) ? |
Should be within a week, just need to get my head around a few things first... not a fan of iOS dev :( |
hahahha...Thanks buddy for the update! |
@Ehesp |
Just android, working on ios now. |
Hey all 👋 There's a draft PR available which fixes this issue and others, please check it out: #3339 We'll be doing a RC release once a few more things are implemented. |
Hi, I have build release android to try react-native firebase V6 and using notifee to display notifcation, background and foreground working well in debug, but in release, just background is working, while foreground is failed. |
Hi there @programmer-RN I strongly recommend you open an issue with Notifee, as one of the things the Notifee license pays for is support. Honestly that's really the whole point of the fee, reliable support :-). Foreground notifications is a notifee function not a react-native-firebase thing |
Edit: I found in old document. The onMessage fire with
data-only messages from FCM
Is this true in this version?
Issue
I installed successfuly react-native-firebase. I got FCM Token then send message from Firebase Console, and i got this issue. When app in background and killed mode, i got notification. But when in foreground the onMessage event doesn't fire.
My physical device :
iPhone 6
iOS:
11.4
Project Files
Javascript
My code
package.json
:firebase.json
for react-native-firebase v6:# N/A
iOS
Click To Expand
ios/Podfile
:AppDelegate.m
:Environment
Click To Expand
react-native info
output:react-native-firebase
version you're using that has this issue:v6.2.0
Firebase
module(s) you're using that has the issue:Cloud Messaging
TypeScript
?N
Think
react-native-firebase
is great? Please consider supporting all of the project maintainers and contributors by donating via our Open Collective where all contributors can submit expenses. [Learn More]React Native Firebase
andInvertase
on Twitter for updates on the library.The text was updated successfully, but these errors were encountered: