Describe the bug
On both a simulator and a real device, onLaunch and onResume do not fire. I have tested this in Android only, at this point.
To Reproduce
Steps to reproduce the behavior:
firebase_core: ^0.4.3+2 and firebase_messaging: ^6.0.9main.dart. Example is found here: https://github.com/FirebaseExtended/flutterfire/blob/master/packages/firebase_messaging/example/lib/main.dart// OnMessage
test_title and the notification text test_text. on_message appears, with the correct title and body.// OnResume
// OnLaunch
Expected behavior
The expected behavior is the same for both onResume and onLaunch. When the notification is pressed, onResume/onLaunch messages should appear and you should be sent to the items page. Instead, no messages appear and you are sent to the home page.
Flutter Doctor:
[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.15.2 19C57,
locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 11.3.1)
[✓] Android Studio (version 3.5)
[✓] IntelliJ IDEA Ultimate Edition (version 2019.2.2)
[✓] Connected device (1 available)
• No issues found!
Move the _firebaseMessaging.configure() block of code before super.initState();
@superakabo Thank you for the suggestion! I moved super.initState(); to be last in the initState method, but nothing changed.
+1
@JacobFrericks Try adding click_action : FLUTTER_NOTIFICATION_CLICK as a k, v pair in the additional options section and then resending the messages from the console.
@GrahamDi Thank you for your answer, that is indeed what fixed this!
FWIW I didn't think anything in a "data" json applied to me when looking for answers online because I was sending this through the console, not a cloud function. After your answer, I did some more digging, and it seems like the Additional Options section in the console adds the data JSON to the request.
Here's a picture of what I changed in the console:

Also, although unintuitive, once you change this option, you can scroll back up to Step 1 and send a test notification to a single device using its token. It will apply this change as well.
Thanks again, I'll close this issue.
@JacobFrericks Glad I could help. Took me a few months to get to the bottom of why this was happening (kept parking the issue and doing other things after each couple of hours of Googling). Maybe we should should raise an issue about FCM documentation being patchy at best.
@JacobFrericks Try adding click_action : FLUTTER_NOTIFICATION_CLICK as a k, v pair in the additional options section and then resending the messages from the console.
can you explain a bit more about what you are suggesting to do? I am having the exact same problem.
let payload = {
"name":"Prototype",
"notification": {
"title": fname + "pressed button",
"body":Keep ur phone handy.\nTap to track ${fname} details,
"image": picture
},
"data": {
"click-action": "FLUTTER_NOTIFICATION_CLICK",
"user_id": userId,
},
"android": {
"priority": "high",
"notification": {
"color": "#FF4040",
"sound": "default",
"sticky": true,
"notification_priority": "priority_max",
"default_sound": true,
"default_vibrate_timings": true,
"default_light_settings": true,
"visibility": "public",
/*"light_settings": {
/!*"color": {
"red": 255,
"green": 0,
"blue": 0,
"alpha": 0
},*!/
"light_on_duration": "1.0s",
"light_off_duration": "1.0s"
}*/
},
},
"token": snap.data().NotifyToken
};
this is my notification payload in cloud functions. and I have also added FLUTTER_NOTIFICATION_CLICK in Android manifest file in
@Pratiknarola see my previous post. It gives a snapshot of what to add in the firebase console.
To clarify, I did not have to make any code changes. I just had to add what is in the snapshot into the firebase console before sending the notification.
you mean this??
I have deployed a function on the trigger on document change so whenever cloudstore document changes this function gets called and this payload is sent as notification. onMessage works great. onResume and onLaunch never gets called and on notification tap main screen opens and nothing happens.
please can you explain all the steps you did exactly to solve this problem.
@Pratiknarola your code states 'click-action', it should be 'click_action'. Also why does the 'body:' text appear to have no double quotes around it?
Most helpful comment
@GrahamDi Thank you for your answer, that is indeed what fixed this!
FWIW I didn't think anything in a "data" json applied to me when looking for answers online because I was sending this through the console, not a cloud function. After your answer, I did some more digging, and it seems like the Additional Options section in the console adds the data JSON to the request.
Here's a picture of what I changed in the console:

Also, although unintuitive, once you change this option, you can scroll back up to Step 1 and send a test notification to a single device using its token. It will apply this change as well.
Thanks again, I'll close this issue.