-
Notifications
You must be signed in to change notification settings - Fork 4.1k
Open
Labels
Needs AttentionThis issue needs maintainer attention.This issue needs maintainer attention.platform: iosIssues / PRs which are specifically for iOS.Issues / PRs which are specifically for iOS.plugin: messagingtype: bugSomething isn't workingSomething isn't working
Description
Is there an existing issue for this?
- I have searched the existing issues.To pick up a draggable item, press the space bar. While dragging, use the arrow keys to move the item. Press space again to drop the item in its new position, or press escape to cancel.
Which plugins are affected?
Messaging
Which platforms are affected?
iOS
Description
await FirebaseMessaging.instance.getInitialMessage()
is always null when the app is opened from the "killed" state.
The plugin version 15.1.6 (the previous version I used) worked as expected.
iOS 18.3.1
@pragma('vm:entry-point')
Future<void> _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
await Firebase.initializeApp();
RemoteMessage? initialMessage = await FirebaseMessaging.instance.getInitialMessage()
// initialMessage is always null here
}
void main() async {
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
...
}
Reproducing the issue
- Close the app (swipe it away)
- Send a notification via firebase console or with a script (in my case I have a link attached to the notification data)
- Tap the notification
- Observe initialMessage being null
Firebase Core version
3.11.0
Flutter Version
3.27.2
Relevant Log Output
Flutter dependencies
No response
Additional context and comments
No response
Metadata
Metadata
Assignees
Labels
Needs AttentionThis issue needs maintainer attention.This issue needs maintainer attention.platform: iosIssues / PRs which are specifically for iOS.Issues / PRs which are specifically for iOS.plugin: messagingtype: bugSomething isn't workingSomething isn't working
Type
Projects
Milestone
Relationships
Development
Select code repository
Activity
SelaseKay commentedon Feb 17, 2025
Hi @lukyanov, I've been able to reproduce this issue with the
firebase_messaging
example app. As a workaround, add a delay of 3 seconds before callinggetInitialMessage
and see if it resolves your issue.google-oss-bot commentedon Feb 26, 2025
Hey @lukyanov. We need more information to resolve this issue but there hasn't been an update in 7 weekdays. I'm marking the issue as stale and if there are no new updates in the next 7 days I will close it automatically.
If you have more information that will help us get to the bottom of this, just add a comment!
austinwitherspoon commentedon Mar 1, 2025
A portion of users of my app on android have been hitting this issue suddenly over the past few weeks. Not sure if there was an android update that broke it, but for the affected users now every RemoteMessage ends up filled with null values.
fahmisdk6 commentedon Mar 10, 2025
I observe a similar issue on Android, will this issue be resolved?
Kamuel09 commentedon Mar 13, 2025
I’m not sure if this will be a hint, but when the RemoteMessage of getInitialMessage() is null, onMessage.listen does not work in the foreground state. However, when the RemoteMessage of getInitialMessage() is not null, onMessage.listen works in the foreground state.
The test was conducted on the Galaxy S25 Ultra, and normal operation was confirmed on the Galaxy Note 10 Plus and Galaxy S22.
pranil-key commentedon Mar 17, 2025
facing same issue
18 remaining items
MichaelVerdon commentedon May 23, 2025
Hey there @lukyanov does @lirunghi261 solution work for you?
lukyanov commentedon Jun 3, 2025
Well, maybe, I don't know. My initial issue was about the official firebase messaging plugin, not about custom workarounds. So I'm not sure I understand the question. Shouldn't the solution be a part of the plugin itself? Will you just close the issue if the custom workaround works? I'm a bit surprised to be honest.
lukyanov commentedon Jun 3, 2025
It's been more than 3 months from the upgrade (from
15.1.6
to15.2.2
) that broke the behaviour the plugin officially states in its documentation.SelaseKay commentedon Jun 12, 2025
Hi @lukyanov, you mentioned that it works fine on version
15.1.6
, but I'm still able to reproduce the issue on that version. Could you confirm if that version still working as expected for you?WillowWisp commentedon Jun 13, 2025
I cannot even use version
15.1.6
as a temporary workaround because of this issue: #16670May I ask your
firebase_core
andfirebase_messaging
versions?newengine commentedon Jun 24, 2025
I experienced the same issue, any update?
firebase_messaging: ^15.1.6
firebase_core: ^3.12.1
russellwheatley commentedon Jul 17, 2025
Hi @lukyanov - I have had a look into this issue. I'm a bit confused really, the code snippet you provided:
does indeed return a null
initialMessage
, but I would expect it to because the background message handler fires largely before the user has a chance to tap the notification and open the app from a terminated state.However, if I open the app with a notification, and then attempt to retrieve the initialMessage via this button: https://github.com/firebase/flutterfire/blob/main/packages/firebase_messaging/firebase_messaging/example/lib/main.dart#L327
I can retrieve the initialMessage without issue.
I am aware of another issue that might occur; I believe this AppDelegate call handler which retrieves initial message: https://github.com/firebase/flutterfire/blob/main/packages/firebase_messaging/firebase_messaging/ios/firebase_messaging/Sources/firebase_messaging/FLTFirebaseMessagingPlugin.m#L214
Might not have been called before there is a chance to get the initial message via
getInitialMessage()
which is why a delay has been suggested to be 100% sure it has fired.I took a look at the code diff between latest version and the last version you suggested
getInitialMessage()
was working for iOS plugin code: https://github.com/firebase/flutterfire/blob/main/packages/firebase_messaging/firebase_messaging/ios/firebase_messaging/Sources/firebase_messaging/FLTFirebaseMessagingPlugin.mThis is the only PR I could find that changes that file: https://github.com/firebase/flutterfire/pull/13484/files
I don't think this should effect the handling of initial messages.