Skip to content

🐛 [firebase_messaging] Push notifications not working on Android - Different issues #4387

@Asored-D

Description

@Asored-D

Bug report

Describe the bug
Since two weeks I try to setup push notifications for iOS and Android devices. On iOS everything works like a charm. I receive backend and in app notifications as well. But for Android I can't get it to work. I receive neither backend nor in app notifications.

If I try to get a background notification, I get the error:

I/flutter ( 9518): FlutterFire Messaging: An error occurred in your background messaging handler: I/flutter ( 9518): type 'List<dynamic>' is not a subtype of type 'List<String>'
... and the app crashes.

If I try to get an In App Notification the onMessage.listen event not fires. But in the console I get a broadcast received for message with the json object of my notification.

Also the error: java.lang.IllegalArgumentException: Service not registered: lt@c879c4d

I'm sending the notification inside a Firebase Cloud function like this:

const payload: admin.messaging.MessagingPayload = {
    notification: {
        titleLocKey: "new_entry_title",
        bodyLocKey: "new_entry_desc",
        titleLocArgs: `["${enteredUserName}", "${enteredUserID}", "${guestbookID}", "new_entry_added"]`,
        bodyLocArgs: `["${enteredUserName}"]`,
        badge: "1",
        sound: "default",
    },
}

return fcm.sendToDevice(userToken, payload, {
    priority: "high",
});

Steps to reproduce

  1. Setup push notifications like to official example
  2. Try to send a notification with the setup above on an Android device

Expected behavior

I expect that the push notifications are working for both devices with one code base


Additional context

I followed the official migration guide to use the new version of firebase_messaging
(https://firebase.flutter.dev/docs/migration)


Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, 1.22.4, on macOS 11.0.1 20B29 darwin-x64, locale de-DE)
 
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 12.2)
[✓] Android Studio (version 3.5)
[✓] VS Code (version 1.52.0)
[✓] Connected device (2 available)

• No issues found!

Flutter dependencies

Run flutter pub deps -- --style=compact and paste the output below:

Click To Expand
Dart SDK 2.10.4
Flutter SDK 1.22.4
virtual_guestbook 1.0.0+8

dependencies:
- cached_network_image 2.3.2+1 [flutter flutter_cache_manager octo_image]
- carousel_slider 2.2.1 [flutter]
- cupertino_icons 0.1.3
- dio 3.0.10 [http_parser path]
- easy_localization 2.3.3 [flutter intl shared_preferences args path flutter_localizations]
- file_picker 2.0.10 [flutter flutter_web_plugins flutter_plugin_android_lifecycle plugin_platform_interface]
- firebase_core 0.5.3 [firebase_core_platform_interface flutter quiver meta firebase_core_web]
- firebase_database 4.4.0 [flutter firebase_core]
- firebase_messaging 8.0.0-dev.11 [meta flutter firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web]
- firebase_storage 4.0.1 [flutter firebase_core]
- flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine]
- flutter_colorpicker 0.3.4 [flutter]
- flutter_inapp_purchase 3.0.0 [http meta flutter platform]
- flutter_inner_drawer 0.5.7+2 [flutter]
- flutter_launcher_icons 0.8.1 [image args yaml path]
- flutter_localizations 0.0.0 [flutter intl characters collection meta path typed_data vector_math]
- flutter_secure_storage 3.3.5 [meta flutter]
- font_awesome_flutter 8.10.0 [flutter]
- gallery_saver 2.0.1 [flutter path_provider http path]
- get 3.17.1 [flutter]
- get_storage 1.3.2 [flutter path_provider get]
- image 2.1.18 [archive xml meta]
- image_gallery_saver 1.6.4 [flutter]
- intl 0.16.1 [path]
- lottie 0.5.1 [flutter archive characters charcode collection logging meta path vector_math]
- modal_bottom_sheet 0.2.0+1 [flutter]
- multi_image_picker 4.7.14 [flutter meta]
- painter 0.4.0 [flutter]
- path_provider 1.6.24 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows]
- persistent_bottom_nav_bar 2.1.0 [flutter]
- pin_code_fields 5.0.1 [flutter]
- provider 4.3.2+2 [flutter nested collection]
- pull_to_refresh 1.6.2 [flutter]
- share 0.6.5+2 [meta mime flutter]
- uuid 2.2.2 [crypto convert]
- video_compress 2.1.0 [flutter]
- video_player 0.11.1+2 [meta video_player_platform_interface video_player_web flutter]
- zefyr 0.12.0 [flutter collection url_launcher quill_delta notus meta quiver_hashcode]

dev dependencies:
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters charcode collection matcher meta source_span stream_channel string_scanner term_glyph typed_data]

transitive dependencies:
- archive 2.0.13 [crypto args path]
- args 1.6.0
- async 2.5.0-nullsafety.1 [collection]
- boolean_selector 2.1.0-nullsafety.1 [source_span string_scanner]
- characters 1.1.0-nullsafety.3
- charcode 1.2.0-nullsafety.1
- clock 1.1.0-nullsafety.1
- collection 1.15.0-nullsafety.3
- convert 2.1.1 [charcode typed_data]
- crypto 2.1.5 [collection convert typed_data]
- fake_async 1.2.0-nullsafety.1 [clock collection]
- ffi 0.1.3
- file 5.2.1 [intl meta path]
- firebase_core_platform_interface 2.1.0 [flutter meta plugin_platform_interface quiver]
- firebase_core_web 0.2.1+1 [firebase_core_platform_interface flutter flutter_web_plugins meta js]
- firebase_messaging_platform_interface 1.0.0-dev.7 [flutter meta firebase_core plugin_platform_interface]
- firebase_messaging_web 0.1.0-dev.2 [flutter flutter_web_plugins meta firebase_core firebase_core_web firebase_messaging_platform_interface js service_worker]
- flutter_blurhash 0.5.0 [flutter meta]
- flutter_cache_manager 1.4.2 [flutter path_provider uuid http path sqflite pedantic clock file rxdart]
- flutter_plugin_android_lifecycle 1.0.11 [flutter]
- flutter_web_plugins 0.0.0 [flutter characters collection meta typed_data vector_math]
- http 0.12.2 [http_parser path pedantic]
- http_parser 3.1.4 [charcode collection source_span string_scanner typed_data]
- js 0.6.2
- logging 0.11.4
- matcher 0.12.10-nullsafety.1 [stack_trace]
- meta 1.3.0-nullsafety.3
- mime 0.9.7
- nested 0.0.4 [flutter]
- notus 0.1.5 [collection meta quill_delta quiver_hashcode]
- octo_image 0.3.0 [flutter flutter_blurhash]
- path 1.8.0-nullsafety.1
- path_provider_linux 0.0.1+2 [path xdg_directories path_provider_platform_interface flutter]
- path_provider_macos 0.0.4+4 [flutter]
- path_provider_platform_interface 1.0.3 [flutter meta platform plugin_platform_interface]
- path_provider_windows 0.0.4+1 [path_provider_platform_interface meta path flutter ffi win32]
- pedantic 1.9.2 [meta]
- petitparser 3.1.0 [meta]
- platform 2.2.1
- plugin_platform_interface 1.0.3 [meta]
- process 3.0.13 [file intl meta path platform]
- quill_delta 1.1.3 [collection quiver_hashcode]
- quiver 2.1.3 [matcher meta]
- quiver_hashcode 2.0.0
- rxdart 0.24.1
- service_worker 0.2.4 [js]
- shared_preferences 0.5.12+4 [meta flutter shared_preferences_platform_interface shared_preferences_linux shared_preferences_macos shared_preferences_web shared_preferences_windows]
- shared_preferences_linux 0.0.2+4 [file flutter meta path path_provider_linux shared_preferences_platform_interface]
- shared_preferences_macos 0.0.1+11 [shared_preferences_platform_interface flutter]
- shared_preferences_platform_interface 1.0.4 [meta flutter]
- shared_preferences_web 0.1.2+7 [shared_preferences_platform_interface flutter flutter_web_plugins meta]
- shared_preferences_windows 0.0.1+3 [shared_preferences_platform_interface flutter ffi file meta path path_provider_platform_interface path_provider_windows]
- sky_engine 0.0.99
- source_span 1.8.0-nullsafety.2 [charcode collection path term_glyph]
- sqflite 1.3.1+1 [flutter sqflite_common path]
- sqflite_common 1.0.2+1 [synchronized path meta]
- stack_trace 1.10.0-nullsafety.1 [path]
- stream_channel 2.1.0-nullsafety.1 [async]
- string_scanner 1.1.0-nullsafety.1 [charcode source_span]
- synchronized 2.2.0+2
- term_glyph 1.2.0-nullsafety.1
- test_api 0.2.19-nullsafety.2 [async boolean_selector collection meta path source_span stack_trace stream_channel string_scanner term_glyph matcher]
- typed_data 1.3.0-nullsafety.3 [collection]
- url_launcher 5.7.2 [flutter url_launcher_platform_interface url_launcher_web url_launcher_linux url_launcher_macos url_launcher_windows]
- url_launcher_linux 0.0.1+1 [flutter]
- url_launcher_macos 0.0.1+8 [flutter]
- url_launcher_platform_interface 1.0.8 [flutter meta plugin_platform_interface]
- url_launcher_web 0.1.4+1 [url_launcher_platform_interface flutter flutter_web_plugins meta]
- url_launcher_windows 0.0.1+1 [flutter]
- vector_math 2.1.0-nullsafety.3
- video_player_platform_interface 2.2.0 [flutter meta]
- video_player_web 0.1.4 [flutter flutter_web_plugins meta video_player_platform_interface]
- win32 1.7.3 [ffi]
- xdg_directories 0.1.2 [meta path process]
- xml 4.5.1 [collection convert meta petitparser]
- yaml 2.2.1 [charcode collection string_scanner source_span]

Is this a known bug?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions