-
Notifications
You must be signed in to change notification settings - Fork 4k
firebase messaging: RemoteMessage contains null values or is null for valid messages on random android devices #17164
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
hey @austinwitherspoon it's happen on our app too without any changes on code I test it and able to reproduce the same issue When user trigger back button android until it close app (background state) & then multiple Push Notification (PN) arrives, when user click a notification it will reopen the app, but after that the strange part is happens.. we found that on foreground state will have payload data is empty too STR (Step to Reproduce) :
can anyone check maybe there are some issues on Firebase side? |
I'm also facing the same issue for random users Users initially receive notifications as expected, but after receiving 2-3 notifications, both the data and notification objects become null. This issue persists even when the app is in the foreground. Once this occurs, users stop receiving notifications altogether until they either clear the app data or reinstall the app. However, after receiving another 2-3 notifications, the issue reoccurs. |
Hi @austinwitherspoon, thanks for the report. Unfortunately, we can't do much without a reproducible example. I tested with the firebase_messaging example app but couldn't reproduce the issue. Since this started happening on a previously working version, it may be an upstream issue. |
It's very difficult to reproduce, but I do think it's a pretty major issue if something like 5% of my users suddenly can't use notifications. I'm not sure what other repo to create an issue in, the only one I can confirm the issue is coming from is flutterfire, and I'm not familiar enough with the flutterfire codebase to know how to confidently identify where the problem is actually coming from |
hey @SelaseKay thankyou for the answer, can you try the STR (Step to Reproduce) on my reply before? it should be able to reproduce the issue by using that STR
can you mention any code on flutterfire / firebase that may be an upstream issue, so that we can investigate it ? |
@rizaldi-wiratama I wasn't able to reproduce using your steps exactly, but I have seen logs of this happening from user devices. I really think this must be a bug that only occurs on certain devices, perhaps a race condition bug in flutterfire somehow relating to phone speed or internet speed? Only specific users will have the issue, but it's across different android versions and phone manufactures (including google's pixel phones!) But I have tried on my own personal pixel phone, and I've tried on a samsung phone with the same model as a user who had the issue, and haven't been able to replicate it. |
Hi @austinwitherspoon, as I mentioned earlier, it’s challenging to investigate a fix without a reliable way to reproduce the issue. Could you share the version of firebase_messaging where this is occurring? |
Confirmed on |
Confirmed on |
Hey there, I am also unable to reproduce the issue, issues like this are notoriously difficult to diagnose when it is happening in production to a number of users. If a MCVE is given here I would be happy to look at it. In the meantime I can only encourage users to check out our implementation on the example application: https://github.com/firebase/flutterfire/tree/main/packages/firebase_messaging/firebase_messaging/example |
As far as I can tell, this isn't an implementation issue. The code I'm using is almost exactly copied and pasted from the examples. This seems like possibly some sort of race condition in the firebase messaging code. @rizaldi-wiratama , you're getting this issue consistently on your device right? I wonder if we can figure out a pattern somehow. What kind of device are you using, and what kind of internet connection do you have. I don't see the issue on my devices (pixel 6 pro, pixel 7a), my emulator, or on any of the galaxy test devices you can borrow on Samsung's developer website. I have gigabit fiber internet, so maybe I should try seeing if I can reproduce it on a bad internet connection? |
I found this really helpful thread for the react native plugin: It seems like maybe this is an issue when Google Play Services proxies the notification, and the plugin isn't reading it properly? They suggested adding a line to What did fix the issue was updating my notification code on the server side so the android message property had Note: This isn't in the official firebase sdks like the one for Python, you have to send your own raw API request to use it! |
hello @austinwitherspoon I just want to confirm that using server side to send Thankyou so much @austinwitherspoon and all I think for now we can close this issue |
Hi @austinwitherspoon , @rizaldi-wiratama , thanks for sharing your findings. Much appreciated. |
I am also experiencing the issue where RemoteMessage is being delivered as null on my Galaxy S25 Ultra. |
Is there an existing issue for this?
Which plugins are affected?
Messaging
Which platforms are affected?
Android
Description
Unfortunately I cannot provide a minimal reproducible example because this error isn't reproducible. I've tried a dozen different devices (primarily samsung and google phones), with different android versions (13-15) and cannot reproduce the issue myself, which makes debugging a nightmare.
But I'm getting reports from users and logs to back them up that confirm that some phones will receive null messages from firebase.
The notification is sent with the same payload to multiple users, and it works on most devices, so the message payload doesn't appear to be a factor.
FirebaseMessaging.onBackgroundMessage will provide a
RemoteMessage
with no actual values. I logged the result ofmessage.toMap()
to troubleshoot, and this is what it spits out:When the user actually taps on the notification and launches the app,
FirebaseMessaging.instance.getInitialMessage()
will returnnull
.Again, this works fine on 95% of my users devices. The bug is consistent for that device, which appears to always receive null values for valid notifications. The notifications display fine on their phone. It's just the
RemoteMessage
object that is either null or contains null values. other users receiving the same notification on the same model of phone may not have the issue.Another really interesting note is that this issue popped up after months of no updates to the app - users reported the notifications worked fine, and then two weeks ago started reporting issues despite no updates being made to the app since the beginning of January!. To me this seemed to indicate that maybe something changed on the OS that broke firebase messaging, but I haven't been able to reproduce it myself with any android version.
As a workaround, I've added the
receive_intent
package to my app and on android devices when the app launches, I can manually extract the notification data from the Intent and handle the notification, but the backgroundMessage handler is completely broken for those users.Here's a list of some of the devices that users reporting the issue have:
Reproducing the issue
No known reproduction steps, the issue appears to be completely random based on your device regardless of phone model or android version.
Firebase Core version
3.12.1
Flutter Version
3.24.4
Relevant Log Output
Flutter dependencies
Expand
Flutter dependencies
snippetAdditional context and comments
No response
The text was updated successfully, but these errors were encountered: