firebase / flutterfire

🔥 A collection of Firebase plugins for Flutter apps.
https://firebase.google.com/docs/flutter/setup
BSD 3-Clause "New" or "Revised" License
8.62k stars 3.95k forks source link

[firebase_messaging]: notifications sent from other plugins don't show on iOS (e.g. background_downloader) #13232

Closed mattia-venturini closed 2 weeks ago

mattia-venturini commented 2 weeks ago

Is there an existing issue for this?

Which plugins are affected?

Messaging

Which platforms are affected?

iOS

Description

I have an app using both firebase_messaging for remote notification and background_downloader for file downloading.

background_downloader should trigger a notification when downloading a file, but that does not work on ios. It works fine if the project does not use firebase_messaging, so there is probably some conflict on the plugin side, as pointed out in this issue.

Can this be solved? Or is there a workaround?

Reproducing the issue

  1. Download the repo from https://github.com/781flyingdutchman/background_downloader and open the example project
  2. Run it on iOS (I use the simulator): you should se that the notification appear in the Notification Center when you press "download"
  3. Add the dependency firebase_messaging: ^15.0.3 in pubspec.yaml
  4. flutter clean && flutter pub get && cd ios && pod install
  5. Run the app again: the notification doesn't appear anymore

Firebase Core version

3.4.0

Flutter Version

3.22.2

Relevant Log Output

No response

Flutter dependencies

Expand Flutter dependencies snippet
```yaml Dart SDK 3.4.3 Flutter SDK 3.22.2 background_downloader_example 2.0.0 dependencies: - background_downloader 8.5.3 [flutter logging http path_provider path async mime collection] - firebase_messaging 15.1.0 [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] - logging 1.2.0 - path 1.9.0 - path_provider 2.1.4 [flutter path_provider_android path_provider_foundation path_provider_linux path_provider_platform_interface path_provider_windows] - provider 6.1.2 [collection flutter nested] dev dependencies: - flutter_lints 3.0.2 [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] - integration_test 0.0.0 [flutter flutter_driver flutter_test path vm_service async boolean_selector characters clock collection fake_async file leak_tracker leak_tracker_flutter_testing leak_tracker_testing matcher material_color_utilities meta source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api vector_math webdriver] transitive dependencies: - _flutterfire_internals 1.3.41 [collection firebase_core firebase_core_platform_interface flutter meta] - async 2.11.0 [collection meta] - boolean_selector 2.1.1 [source_span string_scanner] - characters 1.3.0 - clock 1.1.1 - collection 1.18.0 - fake_async 1.3.1 [clock collection] - ffi 2.1.3 - file 7.0.0 [meta path] - firebase_core 3.4.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_core_platform_interface 5.2.1 [collection flutter flutter_test meta plugin_platform_interface] - firebase_core_web 2.17.5 [firebase_core_platform_interface flutter flutter_web_plugins meta web] - firebase_messaging_platform_interface 4.5.43 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_messaging_web 3.8.13 [_flutterfire_internals firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins meta web] - flutter_driver 0.0.0 [file flutter flutter_test fuchsia_remote_debug_protocol path meta vm_service webdriver async boolean_selector characters clock collection leak_tracker leak_tracker_flutter_testing leak_tracker_testing matcher material_color_utilities platform process source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api vector_math] - flutter_web_plugins 0.0.0 [flutter characters collection material_color_utilities meta vector_math] - fuchsia_remote_debug_protocol 0.0.0 [process vm_service file meta path platform] - http 1.2.2 [async http_parser meta web] - http_parser 4.0.2 [collection source_span string_scanner typed_data] - leak_tracker 10.0.4 [clock collection meta path vm_service] - leak_tracker_flutter_testing 3.0.3 [flutter leak_tracker leak_tracker_testing matcher meta] - leak_tracker_testing 3.0.1 [leak_tracker matcher meta] - lints 3.0.0 - matcher 0.12.16+1 [async meta stack_trace term_glyph test_api] - material_color_utilities 0.8.0 [collection] - meta 1.12.0 - mime 1.0.6 - nested 1.0.0 [flutter] - path_provider_android 2.2.10 [flutter path_provider_platform_interface] - path_provider_foundation 2.4.0 [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] - platform 3.1.4 - plugin_platform_interface 2.1.8 [meta] - process 5.0.2 [file path platform] - sky_engine 0.0.99 - source_span 1.10.0 [collection path term_glyph] - stack_trace 1.11.1 [path] - stream_channel 2.1.2 [async] - string_scanner 1.2.0 [source_span] - sync_http 0.3.1 - term_glyph 1.2.1 - test_api 0.7.0 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph] - typed_data 1.3.2 [collection] - vector_math 2.1.4 - vm_service 14.2.1 - web 0.5.1 - webdriver 3.0.3 [matcher path stack_trace sync_http] - xdg_directories 1.0.4 [meta path] ```

Additional context and comments

No response

SelaseKay commented 2 weeks ago

Hi @mattia-venturini . I'm unable to reproduce this issue. I was able to run the background_downloader example app but I didn't receive a notification when I tapped on the download button. I experienced this without adding the firebase_messaging plugin. Could you provide a screenshot or screen recording?

mattia-venturini commented 2 weeks ago

Hi, thank you for your reply. The notification does not appear in foreground, but I can see it in the Notification Center. Here is a recording of the example app without firebase_messaging, which is the expected behaviour. I recorded it on an iPhone SE simulator with iOS 17.5

https://github.com/user-attachments/assets/cf393d27-607d-420f-addd-7ba35bc1bd0f

SelaseKay commented 2 weeks ago

Hi @mattia-venturini , thanks for sharing the recording. Ideally, it would be better for background_downloader to accommodate FlutterFire, rather than the other way around. Unfortunately, this is beyond our control.

mattia-venturini commented 2 weeks ago

Ideally, it would be better for background_downloader to accommodate FlutterFire, rather than the other way around.

But how should this be done?

Basing on the discussion with the other plugin's owner (the comment here) the problem seems to be that one plugin receives the notification and doesn't pass to the other ones. Unfortunately I don't know what to look to better address this problem (I have no experience in plugins development), so I would be grateful if you could point me in the right direction.