-
Notifications
You must be signed in to change notification settings - Fork 4k
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
[firebase_messaging] notification title/body is missing for onResume and onLaunch #2012
Comments
I am having the same issue |
You should add your title and body in data like below:
|
@mankeomorakort I'm aware that I can push the title and body through via data, but doesn't that negate the reason for having the "title" and "text" options available in Step 1 of the Firebase console? Why even have these as options if they don't work? I believe this is a bug that requires fixing for Flutter, and using the custom data in Step 5 with the keys "title" and "body" is just a workaround. |
I confirm this used to work a couple of months ago; it is definitely a bug somewhere. Adding |
Hi @JacobFrericks |
@iapicca |
Hi @JacobFrericks |
So what's the next step for this? Is there any testing that I can do? It's been almost two weeks, just wanted to get an update. |
I ran into the same issue as well. This is very frustrating as we need to do further processing of the notification in our app. It's hard to believe this has been reported 6 weeks ago and is very easy to reproduce, but hasn't been fixed yet. This breaks every app that actually wants to do anything with the contents of a notification. |
I also encountered the same issue: send notification from cloud: I tried:
Actually, I still think that my code is in error, but I could not find the error anywhere. NotificationService :
pubspec.yaml
can anyone help me, please :) |
@hungbu when you say that it "works normally" are you getting the title/body for onResume/onLaunch? I just updated flutter for the stable, then dev, then master channels, all with the same results as the first post: title/body are appearing in onMessage, but not onResume/onLaunch. As for your question, I would recommend making a new issue. |
I also updated to the latest firebase_core and firebase_messaging with the same result. firebase_core: ^0.4.4+3 |
So, I got tired of waiting for this fix to be prioritized/fixed, and created a workaround. I pushed it to my sandbox repo. Here's the code changes I performed to create the workaround (it should be a simple copy/paste for most people): https://github.com/JacobFrericks/sandbox/commit/398d1763cfb195a1f68a6f2ed9b8b8b281b9e606 Below is the code in case the link gets broken somewhere down the line:
This workaround requires two additional data fields to be sent from the console: "title" and "body". The workaround moves these two fields from the data section of the message to the notification (as if the message had them all along). The advantage of this workaround is it won't require any code changes when Flutter fixes this issue. You simply need to provide the title and body in the flutter console as normal, and the workaround method do nothing. |
@JacobFrericks even I am tired.... Workarounds, Workarounds, Workarounds... |
I am having the same issue using firebase_messaging: ^6.0.13 |
I have the same issue in |
I have this problem for iOs but it works fine on Android. |
This is still happening when using |
I have the same error on Android using firebase_messaging: ^7.0.3. |
This issue still happening with flutter on firebase_messaging: ^7.0.3. alternatively can use message Custom data to send the same data |
I have the same problem. I could not get the title and body when notification is send from firebase console. onMessage there is no problem but onResume and onLaunch notification is empty like ''{notification: {}, data: {collapse_key: com.exaple.vedat, google.original_priority: high, google.sent_time: 1603976954143, google.delivered_priority: high, google.ttl: 2419200, from: 117431216057, click_action: FLUTTER_NOTIFICATION_CLICK, google.message_id: 0:1603976954318920%8a5620e18a5620e1}}" |
Because all things should be balanced, I have the same problem on Android but not on iOS. |
I have the same problem but now it doesen't even work with onMessage(). |
Problem is still present (at least on Android 10) with version |
Hey @JacobFrericks, we're now on version 9 and the |
Describe the bug
The callbacks are set to print the message when it's received. When I send a notification to my app from the firebase console, I correctly get a title and body for onMessage, but onResume, I get an empty object under the Notification parent (see below for an example of what I see)
To Reproduce
Steps to reproduce the behavior:
Follow the instructions for adding firebase to your app: https://firebase.google.com/docs/flutter/setup?platform=android
(NOTE: I have added two packages firebase_core: ^0.4.4 and firebase_messaging: ^6.0.9
Copy and paste the example into main.dart. Example is found here: https://github.com/FirebaseExtended/flutterfire/blob/master/packages/firebase_messaging/example/lib/main.dart
Start the app in either a simulator or a real device, and copy the token printed in the terminal. Keep the application open.
NOTE: I have also published this code in a repository. If you want to skip steps 1-2, you can clone it here: https://github.com/JacobFrericks/sandbox
// OnMessage
4. Go to your firebase cloud_messaging page, and send a notification with the notification title test_title and the notification text test_text.
5. Click "Send test message", and paste in the token. Click "Test".
6. Observe the console. on_message appears, with the correct title and body. Here's my example:
// OnResume
7. push the home button on the device, sending the application into the background.
8. Repeat steps 4-5.
9. Press the notification, which will open the app.
10. Observe the console. onResume appears, with no title or body. Here's my example:
// OnLaunch
11. press the square multitask button and swipe up/down on the application, completely closing it.
12. Repeat steps 7-9.
13. This is hard to view, because closing the application disconnects from the console. I suspect it is the same as onResume, as the two receive the notification in the same way.
Expected behavior
The expected behavior is that when the notification is received, onResume/onLaunch messages should contain both a title and body under the notification parent. Instead, an empty notification object appears.
Flutter Doctor:
The text was updated successfully, but these errors were encountered: