Skip to content

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

Closed
1 task done
austinwitherspoon opened this issue Mar 3, 2025 · 15 comments
Labels
Needs Attention This issue needs maintainer attention. platform: android Issues / PRs which are specifically for Android. plugin: messaging resolution: solution-provided A solution has been provided in the issue. type: bug Something isn't working

Comments

@austinwitherspoon
Copy link

Is there an existing issue for this?

  • I have searched the existing issues.

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 of message.toMap() to troubleshoot, and this is what it spits out:

{} {_firebaseMessagingBackgroundHandler} {About to catalog notification for {senderId: null, category: null, collapseKey: null, contentAvailable: false, data: {}, from: null, messageId: null, messageType: null, mutableContent: false, notification: null, sentTime: 0, threadId: null, ttl: 0}} {LogLevel.INFO} {01 March 2025 11:13:24 AM}

When the user actually taps on the notification and launches the app, FirebaseMessaging.instance.getInitialMessage() will return null.

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:

  • Samsung Galaxy S22 Ultra
  • Pixel 7 Pro - Android 15
  • Pixel 6A - Android 15
  • Moto G (2022) Android 12
  • Galaxy S25 Ultra, Android 15
  • Galaxy S20+ Android 13

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 snippet
dependencies:
- bluesky 0.15.8 [atproto_core atproto freezed_annotation json_annotation lex_annotation]
- cloud_firestore 5.4.5 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta]
- cupertino_icons 1.0.8
- f_logs 2.0.1 [flutter sembast path_provider intl xxtea meta path stack_trace]
- firebase_core 3.12.1 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_messaging 15.2.4 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine]
- flutter_background_service 5.0.10 [flutter flutter_background_service_platform_interface flutter_background_service_android flutter_background_service_ios]
- provider 6.1.2 [collection flutter nested]
- receive_intent 0.2.7 [flutter]
- sentry_flutter 8.13.2 [flutter flutter_web_plugins sentry package_info_plus meta ffi file collection]
- shared_preferences 2.3.3 [flutter shared_preferences_android shared_preferences_foundation shared_preferences_linux shared_preferences_platform_interface shared_preferences_web shared_preferences_windows]
- url_launcher 6.3.1 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows]

dev dependencies:
- flutter_launcher_icons 0.13.1 [args checked_yaml cli_util image json_annotation path yaml]
- flutter_lints 4.0.0 [lints]
- flutter_test 0.0.0 [flutter test_api matcher path fake_async clock stack_trace vector_math leak_tracker_flutter_testing async boolean_selector characters collection leak_tracker leak_tracker_testing material_color_utilities meta source_span stream_channel string_scanner term_glyph vm_service]

transitive dependencies:
- _flutterfire_internals 1.3.53 [collection firebase_core firebase_core_platform_interface flutter meta]
- archive 3.6.1 [crypto path]
- args 2.6.0
- async 2.11.0 [collection meta]
- at_identifier 0.2.2
- at_uri 0.3.2 [at_identifier nsid]
- atproto 0.11.5 [atproto_core freezed_annotation json_annotation lex_annotation]
- atproto_core 0.9.4 [xrpc at_uri freezed_annotation json_annotation cbor multiformats universal_io]
- base_codecs 1.0.1 [crypto]
- boolean_selector 2.1.1 [source_span string_scanner]
- buffer 1.2.3
- cbor 6.3.3 [collection typed_data hex convert ieee754 meta]
- characters 1.3.0
- checked_yaml 2.0.3 [json_annotation source_span yaml]
- cli_util 0.4.2 [meta path]
- clock 1.1.1
- cloud_firestore_platform_interface 6.4.4 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- cloud_firestore_web 4.3.3 [_flutterfire_internals cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins]
- collection 1.18.0
- convert 3.1.2 [typed_data]
- crypto 3.0.6 [typed_data]
- dart_multihash 1.0.1 [buffer]
- fake_async 1.3.1 [clock collection]
- ffi 2.1.3
- file 7.0.1 [meta path]
- firebase_core_platform_interface 5.4.0 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_core_web 2.21.1 [firebase_core_platform_interface flutter flutter_web_plugins meta web]
- firebase_messaging_platform_interface 4.6.4 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_messaging_web 3.10.4 [_flutterfire_internals firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins meta web]
- fixnum 1.1.1
- flutter_background_service_android 6.2.7 [flutter flutter_background_service_platform_interface]
- flutter_background_service_ios 5.0.3 [flutter flutter_background_service_platform_interface]
- flutter_background_service_platform_interface 5.1.2 [flutter platform plugin_platform_interface]
- flutter_web_plugins 0.0.0 [flutter characters collection material_color_utilities meta vector_math]
- freezed_annotation 2.4.4 [collection json_annotation meta]
- hex 0.2.0
- http 1.2.2 [async http_parser meta web]
- http_parser 4.0.2 [collection source_span string_scanner typed_data]
- ieee754 1.0.3 [meta]
- image 4.3.0 [archive meta xml]
- intl 0.17.0 [clock path]
- json_annotation 4.9.0 [meta]
- leak_tracker 10.0.5 [clock collection meta path vm_service]
- leak_tracker_flutter_testing 3.0.5 [flutter leak_tracker leak_tracker_testing matcher meta]
- leak_tracker_testing 3.0.1 [leak_tracker matcher meta]
- lex_annotation 0.0.2
- lints 4.0.0
- matcher 0.12.16+1 [async meta stack_trace term_glyph test_api]
- material_color_utilities 0.11.1 [collection]
- meta 1.15.0
- mime 1.0.6
- multiformats 0.2.3 [base_codecs crypto dart_multihash]
- nested 1.0.0 [flutter]
- nsid 0.4.1
- package_info_plus 8.1.1 [ffi flutter flutter_web_plugins http meta path package_info_plus_platform_interface web win32 clock]
- package_info_plus_platform_interface 3.0.1 [flutter meta plugin_platform_interface]
- path 1.9.0
- path_provider 2.1.5 [flutter path_provider_android path_provider_foundation path_provider_linux path_provider_platform_interface path_provider_windows]
- path_provider_android 2.2.15 [flutter path_provider_platform_interface]
- path_provider_foundation 2.4.1 [flutter path_provider_platform_interface]
- path_provider_linux 2.2.1 [ffi flutter path path_provider_platform_interface xdg_directories]
- path_provider_platform_interface 2.1.2 [flutter platform plugin_platform_interface]
- path_provider_windows 2.3.0 [ffi flutter path path_provider_platform_interface]
- petitparser 6.0.2 [meta]
- platform 3.1.6
- plugin_platform_interface 2.1.8 [meta]
- sembast 3.8.2 [meta path synchronized]
- sentry 8.13.2 [http meta stack_trace uuid collection]
- shared_preferences_android 2.3.3 [flutter shared_preferences_platform_interface]
- shared_preferences_foundation 2.5.3 [flutter shared_preferences_platform_interface]
- shared_preferences_linux 2.4.1 [file flutter path path_provider_linux path_provider_platform_interface shared_preferences_platform_interface]
- shared_preferences_platform_interface 2.4.1 [flutter plugin_platform_interface]
- shared_preferences_web 2.4.2 [flutter flutter_web_plugins shared_preferences_platform_interface web]
- shared_preferences_windows 2.4.1 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface]
- sky_engine 0.0.99
- source_span 1.10.0 [collection path term_glyph]
- sprintf 7.0.0
- stack_trace 1.11.1 [path]
- stream_channel 2.1.2 [async]
- string_scanner 1.2.0 [source_span]
- synchronized 3.3.0+3
- term_glyph 1.2.1
- test_api 0.7.2 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph]
- typed_data 1.4.0 [collection]
- universal_io 2.2.2 [collection meta typed_data]
- url_launcher_android 6.3.14 [flutter url_launcher_platform_interface]
- url_launcher_ios 6.3.1 [flutter url_launcher_platform_interface]
- url_launcher_linux 3.2.0 [flutter url_launcher_platform_interface]
- url_launcher_macos 3.2.1 [flutter url_launcher_platform_interface]
- url_launcher_platform_interface 2.3.2 [flutter plugin_platform_interface]
- url_launcher_web 2.3.3 [flutter flutter_web_plugins url_launcher_platform_interface web]
- url_launcher_windows 3.1.3 [flutter url_launcher_platform_interface]
- uuid 4.5.1 [crypto sprintf meta fixnum]
- vector_math 2.1.4
- vm_service 14.2.5
- web 1.1.0
- web_socket_channel 2.4.0 [async crypto stream_channel]
- win32 5.9.0 [ffi]
- xdg_directories 1.1.0 [meta path]
- xml 6.5.0 [collection meta petitparser]
- xrpc 0.5.1 [http nsid freezed_annotation json_annotation mime web_socket_channel]
- xxtea 2.1.0
- yaml 3.1.2 [collection source_span string_scanner]

Additional context and comments

No response

@austinwitherspoon austinwitherspoon added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Mar 3, 2025
@rizaldi-wiratama
Copy link

rizaldi-wiratama commented Mar 3, 2025

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) :

  1. Trigger back button android until close app (background state)
  2. Multiple PN (Push Notification) arrives on background state
  3. Click a PN from Notification Tray → it will reopen app
  4. When reopen app all notification that is coming from background state have some payload data empty (SS 1)
  5. After on foreground state if there are new PN coming it will have payload data empty & payload notification null too (SS 2)

Image

Image

can anyone check maybe there are some issues on Firebase side?

@SelaseKay SelaseKay added plugin: messaging platform: android Issues / PRs which are specifically for Android. labels Mar 4, 2025
@AK47-23
Copy link

AK47-23 commented Mar 4, 2025

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.

Image

@SelaseKay
Copy link
Contributor

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.

@austinwitherspoon
Copy link
Author

austinwitherspoon commented Mar 4, 2025

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

@rizaldi-wiratama
Copy link

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

Since this started happening on a previously working version, it may be an upstream issue.

can you mention any code on flutterfire / firebase that may be an upstream issue, so that we can investigate it ?

@austinwitherspoon
Copy link
Author

@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.

@SelaseKay
Copy link
Contributor

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?

@SelaseKay SelaseKay added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Mar 5, 2025
@austinwitherspoon
Copy link
Author

Confirmed on ^15.1.4 and ^15.2.4

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Mar 5, 2025
@AK47-23
Copy link

AK47-23 commented Mar 6, 2025

Confirmed on 15.0.2 for our users

@MichaelVerdon
Copy link
Contributor

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

@MichaelVerdon MichaelVerdon added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Mar 6, 2025
@austinwitherspoon
Copy link
Author

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?

@google-oss-bot google-oss-bot added Needs Attention This issue needs maintainer attention. and removed blocked: customer-response Waiting for customer response, e.g. more information was requested. labels Mar 6, 2025
@austinwitherspoon
Copy link
Author

I found this really helpful thread for the react native plugin:
invertase/react-native-firebase#8392

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 AndroidManifest.xml but that didn't fix it.

What did fix the issue was updating my notification code on the server side so the android message property had "proxy": "DENY" in it. Once I made that change, all users that had the issue in my app started reporting it was fixed.

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!

@rizaldi-wiratama
Copy link

hello @austinwitherspoon I just want to confirm that using server side to send AndroidNotification with key-value "proxy" : "DENY" (FCM Rest API docs on here & here for proxy enum) is solving the issue as stated on firebase docs here

Thankyou so much @austinwitherspoon and all

I think for now we can close this issue

@SelaseKay
Copy link
Contributor

Hi @austinwitherspoon , @rizaldi-wiratama , thanks for sharing your findings. Much appreciated.

@SelaseKay SelaseKay added the resolution: solution-provided A solution has been provided in the issue. label Mar 10, 2025
@Kamuel09
Copy link

I am also experiencing the issue where RemoteMessage is being delivered as null on my Galaxy S25 Ultra.
In my case, I am using the Admin SDK for Python instead of REST.
How should I proceed with testing or making modifications in this situation?

@firebase firebase locked and limited conversation to collaborators Apr 10, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Needs Attention This issue needs maintainer attention. platform: android Issues / PRs which are specifically for Android. plugin: messaging resolution: solution-provided A solution has been provided in the issue. type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

7 participants