Skip to content

firebase messaging: RemoteMessage contains null values or is null for valid messages on random android devices #17164

Closed
@austinwitherspoon

Description

@austinwitherspoon

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions