-
Notifications
You must be signed in to change notification settings - Fork 2.3k
🔥 onMessage not triggered when using onNotification - V6.0 #3236
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
Comments
I have a very similar setup and am seeing the exact same thing (i.e. double notifications sent thru It may be worth noting that I've only tried sending notifications via the Firebase Cloud Messaging dashboard. I'm not sure if triggering them that way has an special properties but the quickstart guide seems to indicate that they're different than generic "messaging" that might not generate a visible notification. |
FWIW, I just tried removing |
This will be handled in the PR linked above 👍 |
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. |
Hello Guys, Is there any update available on this issue ? |
@ahmad6242 no, it was closed half a year ago with a merged PR. When configured correctly, and when handlers are hooked correctly, and device power management and app state and permissions etc allow, all react-native-firebase messaging APIs are functioning correctly as far as we know. Which is to say it's not easy to get right but it is working as well as it seems possible to make it? |
@mikehardy , Good to hear this. |
@ahmad6242 you don't specify your exact json payload so I'm not sure. In general I try to stay out of helping users with specific messaging problems because it's so specific to app setup and the JSON sent. I want to be very clear that my onMessage handler is called in my app when I send data-only payloads and the app is in foreground. This module works, but the integration and JSON you send must be just right. What is "just right"? You have to read the docs and test and test and test |
Issue
Describe your issue here
My goal is to receive Firebase Cloud Messages on iOS and have a push notification, and also cache the FCM locally in order to view it later.
First attempt is to trigger a local notification (using zo0r notifications library) after receiving the FCM. I have received the FCM and cached and was able to show a local notification but this method doesn't allow me to trigger this local notification when app is in background or killed.
Second attempt is to send a push notification (after specifying the "notification" field in Firebase admin send message function) and add a Data field to the notification. Problem was the data field is not available when the app is in background or killed. I got only the title and body.
onMessage
is not called as well in this method, only onNotification istriggered
.Third attempt is to send two different FCM messages, one with data only and the other with notification. So the push notification is received and onNotification is called but onMessage is never triggered.
So in summary, onMessage is not called when onNotification is called although two different messages are sent (one with notification field and other with data only field).
Below is the backend code that sends the notification:
And below is the code in the React-Native app:
Project Files
Javascript
Click To Expand
package.json
:firebase.json
for react-native-firebase v6:# N/A
iOS
Click To Expand
ios/Podfile
:AppDelegate.m
: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
:// N/A
android/app/build.gradle
:// N/A
android/settings.gradle
:// N/A
MainApplication.java
:// N/A
AndroidManifest.xml
:<!-- N/A -->
Environment
Click To Expand
react-native info
output:react-native-firebase
version you're using that has this issue:6.0.2
Firebase
module(s) you're using that has the issue:Messaging, App
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: