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.68k stars 3.97k forks source link

πŸ› [firebase_messaging] v8.0.0-dev.14 iOS - notification is received, but does not trigger onOpened or onOpenedApp #4833

Closed davidbrenner closed 3 years ago

davidbrenner commented 3 years ago

Bug report

Describe the bug I am able to send/receive notifications on both Android and iOS. On iOS, notifications are not triggering the onMessage or onMessageOpened handlers. I am stumped as to what is going on and have been at this for a couple of days now. This is for a project that started almost a year ago. We've continuously updated and haven't had any major issues with FCM until this most recent upgrade.

Steps to reproduce

Steps to reproduce the behavior:

  1. Upgrade to FCM 8.0.0-dev.14"
  2. Implement onMessage and onMessageOpenedApp
  3. Send notification
  4. Receive notification with app backgrounded
  5. Click to open the notification
  6. onMessageOpenedApp is not called

Expected behavior

Code within onMessageOpenedApp should be executed


Additional context

Behavior was working fine on previous builds of our app.


Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand ``` [βœ“] Flutter (Channel stable, 1.22.6, on macOS 11.1 20C69 darwin-x64, locale en-US) [βœ“] Android toolchain - develop for Android devices (Android SDK version 30.0.2) [βœ“] Xcode - develop for iOS and macOS (Xcode 12.4) [!] Android Studio (version 4.1) βœ— Flutter plugin not installed; this adds Flutter specific functionality. βœ— Dart plugin not installed; this adds Dart specific functionality. [βœ“] VS Code (version 1.52.1) [βœ“] Connected device (2 available) ! Doctor found issues in 1 category. ```

Flutter dependencies

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

Click To Expand ``` Dart SDK 2.10.5 Flutter SDK 1.22.6 my_native_app 1.2.17+147 dependencies: - amplitude_flutter 2.2.3 [flutter] - apple_sign_in 0.1.0 [flutter] - auto_size_text 2.1.0 [flutter] - badges 1.1.6 [flutter] - blobs 1.2.0 [flutter] - carousel_slider 2.3.1 [flutter] - cloud_firestore 0.16.0 [flutter meta quiver firebase_core firebase_core_platform_interface cloud_firestore_platform_interface cloud_firestore_web] - connectivity 2.0.2 [flutter meta connectivity_platform_interface connectivity_macos connectivity_for_web] - contacts_service 0.4.6 [flutter collection quiver] - cupertino_icons 1.0.0 - dartbase_admin 0.1.4 [http grpc protobuf googleapis_auth gcloud json_annotation meta corsac_jwt crypto_keys eosdart_ecc] - device_id 0.2.0 [flutter] - device_info 1.0.0 [flutter device_info_platform_interface] - email_validator 1.0.6 - equatable 1.2.5 [collection meta] - esys_flutter_share 1.0.2 [flutter path_provider] - firebase_analytics 7.0.1 [meta flutter firebase_core firebase_analytics_web firebase_analytics_platform_interface] - firebase_auth 0.20.0+1 [meta firebase_core firebase_core_platform_interface firebase_auth_platform_interface firebase_auth_web flutter] - firebase_core 0.7.0 [firebase_core_platform_interface flutter quiver meta firebase_core_web] - firebase_crashlytics 0.4.0+1 [flutter stack_trace firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface] - firebase_dynamic_links 0.7.0+1 [flutter firebase_core] - firebase_in_app_messaging 0.3.0+1 [meta flutter firebase_core] - firebase_messaging 8.0.0-dev.14 [meta flutter firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web] - firebase_storage 7.0.0 [flutter firebase_core firebase_core_platform_interface firebase_storage_web firebase_storage_platform_interface quiver] - flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine] - flutter_advanced_networkimage 0.8.0 [flutter http path_provider path flutter_svg] - flutter_bloc 6.1.1 [flutter bloc provider] - flutter_cache_manager 2.1.1 [flutter path_provider uuid http path sqflite pedantic clock file rxdart image] - flutter_cache_manager_firebase 1.1.0-beta [flutter flutter_cache_manager firebase_storage path_provider path] - flutter_facebook_login 3.0.0 [flutter collection] - flutter_launcher_icons 0.8.1 [image args yaml path] - flutter_native_timezone 1.0.4 [flutter] - flutter_sms 2.1.1 [flutter url_launcher flutter_web_plugins plugin_platform_interface flutter_user_agent] - flutter_svg 0.18.1 [path_drawing xml vector_math meta flutter] - font_awesome_flutter 8.11.0 [flutter] - get_ip 0.4.0 [flutter] - golden_toolkit 0.8.0 [flutter meta flutter_test] - google_fonts 1.1.2 [flutter http path_provider crypto] - google_sign_in 4.5.9 [google_sign_in_platform_interface flutter meta google_sign_in_web] - image_picker 0.6.7+21 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface] - intercom_flutter 2.2.0 [flutter] - intl 0.16.1 [path] - keyboard_actions 3.3.1+1 [flutter] - keyboard_visibility 0.5.6 [flutter] - lottie 0.7.0+1 [archive characters charcode collection flutter logging meta path vector_math] - native_mixpanel 0.1.2 [flutter] - onesignal_flutter 2.6.2 [flutter] - package_info 0.4.3+2 [flutter] - path_provider 1.6.27 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows] - percent_indicator 2.1.9 [flutter] - permission_handler 5.0.1+1 [flutter meta permission_handler_platform_interface] - provider 4.3.3 [collection flutter nested] - purchases_flutter 2.0.2 [flutter] - share 0.6.5+4 [meta mime flutter] - shared_preferences 0.5.12+4 [meta flutter shared_preferences_platform_interface shared_preferences_linux shared_preferences_macos shared_preferences_web shared_preferences_windows] - streaming_shared_preferences 1.0.2 [flutter shared_preferences meta] - timezone 0.6.1 [path] - url_launcher 5.7.10 [flutter url_launcher_platform_interface url_launcher_web url_launcher_linux url_launcher_macos url_launcher_windows] dev dependencies: - flutter_driver 0.0.0 [file json_rpc_2 meta path web_socket_channel vm_service_client webdriver flutter flutter_test fuchsia_remote_debug_protocol archive args async boolean_selector characters charcode clock collection convert crypto fake_async matcher platform process pub_semver source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api typed_data vector_math] - 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] - test 1.16.0-nullsafety.5 [analyzer async boolean_selector coverage http http_multi_server io js node_preamble package_config path pedantic pool shelf shelf_packages_handler shelf_static shelf_web_socket source_span stack_trace stream_channel typed_data web_socket_channel webkit_inspection_protocol yaml test_api test_core] transitive dependencies: - _discoveryapis_commons 0.2.0 [http] - _fe_analyzer_shared 12.0.0 [meta] - analyzer 0.40.6 [_fe_analyzer_shared args cli_util collection convert crypto glob meta package_config path pub_semver source_span watcher yaml] - archive 2.0.13 [crypto args path] - args 1.6.0 - asn1lib 0.6.5 - async 2.5.0-nullsafety.1 [collection] - bloc 6.1.1 [meta] - boolean_selector 2.1.0-nullsafety.1 [source_span string_scanner] - bs58check 1.0.1 [hex crypto] - built_collection 4.3.2 [collection quiver] - built_value 7.1.0 [built_collection collection fixnum quiver] - characters 1.1.0-nullsafety.3 - charcode 1.2.0-nullsafety.1 - cli_util 0.2.0 [path] - clock 1.1.0-nullsafety.1 - cloud_firestore_platform_interface 3.0.1 [flutter meta collection firebase_core plugin_platform_interface] - cloud_firestore_web 0.3.0+1 [flutter flutter_web_plugins http_parser meta firebase_core firebase_core_web cloud_firestore_platform_interface js] - collection 1.15.0-nullsafety.3 - connectivity_for_web 0.3.1+4 [connectivity_platform_interface flutter_web_plugins flutter] - connectivity_macos 0.1.0+7 [flutter] - connectivity_platform_interface 1.0.6 [flutter meta plugin_platform_interface] - convert 2.1.1 [charcode typed_data] - corsac_jwt 0.2.2 [asn1lib logging pointycastle rsa_pkcs crypto] - coverage 0.14.2 [args logging package_config path source_maps stack_trace vm_service] - crypto 2.1.5 [collection convert typed_data] - crypto_keys 0.1.3 [pointycastle meta built_value built_collection] - device_info_platform_interface 1.0.1 [flutter meta plugin_platform_interface] - eosdart_ecc 0.4.3 [bs58check pointycastle crypto] - fake_async 1.2.0-nullsafety.1 [clock collection] - ffi 0.1.3 - file 6.0.0-nullsafety.2 [meta path] - firebase 7.3.3 [http http_parser js] - firebase_analytics_platform_interface 1.0.3 [flutter meta] - firebase_analytics_web 0.1.1 [flutter flutter_web_plugins firebase firebase_analytics_platform_interface meta] - firebase_auth_platform_interface 3.0.1 [flutter meta firebase_core plugin_platform_interface] - firebase_auth_web 0.3.2+6 [flutter flutter_web_plugins meta http_parser intl firebase_core firebase_core_web firebase_auth_platform_interface js] - firebase_core_platform_interface 3.0.1 [flutter meta plugin_platform_interface quiver] - firebase_core_web 0.2.1+3 [firebase_core_platform_interface flutter flutter_web_plugins meta js] - firebase_crashlytics_platform_interface 1.1.6 [flutter meta collection firebase_core plugin_platform_interface] - firebase_messaging_platform_interface 1.0.0-dev.10 [flutter meta firebase_core plugin_platform_interface] - firebase_messaging_web 0.1.0-dev.5 [flutter flutter_web_plugins meta firebase_core firebase_core_web firebase_messaging_platform_interface js service_worker] - firebase_storage_platform_interface 1.0.4 [flutter meta collection firebase_core plugin_platform_interface] - firebase_storage_web 0.1.1+3 [async crypto firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http js meta] - fixnum 0.10.11 - flutter_plugin_android_lifecycle 1.0.11 [flutter] - flutter_user_agent 1.2.2 [flutter] - flutter_web_plugins 0.0.0 [flutter characters collection meta typed_data vector_math] - fuchsia_remote_debug_protocol 0.0.0 [json_rpc_2 process web_socket_channel flutter_test flutter_driver archive args async boolean_selector charcode clock collection convert crypto fake_async file matcher meta path platform pub_semver source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api typed_data vector_math vm_service_client webdriver] - gcloud 0.7.3 [_discoveryapis_commons googleapis http meta] - glob 1.2.0 [async collection node_io path pedantic string_scanner] - google_sign_in_platform_interface 1.1.2 [flutter meta quiver] - google_sign_in_web 0.9.2 [google_sign_in_platform_interface flutter flutter_web_plugins meta js] - googleapis 0.56.1 [_discoveryapis_commons http] - googleapis_auth 0.2.12+1 [crypto http] - grpc 2.8.0 [async crypto fixnum googleapis_auth meta http http2 protobuf] - hex 0.1.2 - http 0.12.2 [http_parser path pedantic] - http2 1.0.1 - http_multi_server 2.2.0 [async] - http_parser 3.1.4 [charcode collection source_span string_scanner typed_data] - image 2.1.19 [archive xml meta] - image_picker_platform_interface 1.1.1 [flutter meta http plugin_platform_interface] - io 0.3.4 [charcode meta path string_scanner] - js 0.6.3-nullsafety.2 - json_annotation 3.1.1 - json_rpc_2 2.2.2 [stack_trace stream_channel] - 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] - node_interop 1.2.1 [js] - node_io 1.1.1 [node_interop path] - node_preamble 1.4.13 - package_config 1.9.3 [path charcode] - path 1.8.0-nullsafety.1 - path_drawing 0.4.1+1 [vector_math meta path_parsing flutter] - path_parsing 0.1.4 [vector_math meta] - path_provider_linux 0.0.1+2 [path xdg_directories path_provider_platform_interface flutter] - path_provider_macos 0.0.4+8 [flutter] - path_provider_platform_interface 1.0.4 [flutter meta platform plugin_platform_interface] - path_provider_windows 0.0.4+3 [path_provider_platform_interface meta path flutter ffi win32] - pedantic 1.10.0-nullsafety.2 - permission_handler_platform_interface 2.0.1 [flutter meta plugin_platform_interface] - petitparser 3.1.0 [meta] - platform 3.0.0-nullsafety.2 - plugin_platform_interface 1.0.3 [meta] - pointycastle 1.0.2 - pool 1.5.0-nullsafety.2 [async stack_trace] - process 4.0.0-nullsafety.2 [file path platform] - protobuf 1.1.0 [fixnum] - pub_semver 1.4.4 [collection] - quiver 2.1.5 [matcher meta] - rsa_pkcs 1.1.3 [asn1lib] - rxdart 0.25.0 - service_worker 0.2.4 [js] - 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.2+2 [shared_preferences_platform_interface flutter ffi file meta path path_provider_platform_interface path_provider_windows] - shelf 0.7.9 [async collection http_parser path stack_trace stream_channel] - shelf_packages_handler 2.0.0 [path shelf shelf_static] - shelf_static 0.2.9+1 [convert http_parser mime path shelf] - shelf_web_socket 0.2.3 [shelf web_socket_channel stream_channel] - sky_engine 0.0.99 - source_map_stack_trace 2.1.0-nullsafety.3 [path stack_trace source_maps] - source_maps 0.10.10-nullsafety.2 [source_span] - source_span 1.8.0-nullsafety.2 [charcode collection path term_glyph] - sqflite 1.3.2+2 [flutter sqflite_common path] - sqflite_common 1.0.3+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] - sync_http 0.2.0 - 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] - test_core 0.3.12-nullsafety.5 [analyzer async args boolean_selector collection coverage glob io meta package_config path pedantic pool source_map_stack_trace source_maps source_span stack_trace stream_channel vm_service yaml matcher test_api] - typed_data 1.3.0-nullsafety.3 [collection] - url_launcher_linux 0.0.1+4 [flutter] - url_launcher_macos 0.0.1+9 [flutter] - url_launcher_platform_interface 1.0.9 [flutter meta plugin_platform_interface] - url_launcher_web 0.1.5+1 [url_launcher_platform_interface flutter flutter_web_plugins meta] - url_launcher_windows 0.0.1+3 [flutter] - uuid 2.2.2 [crypto convert] - vector_math 2.1.0-nullsafety.3 - vm_service 5.5.0 [meta] - vm_service_client 0.2.6+2 [async collection json_rpc_2 pub_semver source_span stack_trace stream_channel web_socket_channel] - watcher 0.9.7+15 [async path pedantic] - web_socket_channel 1.1.0 [async crypto stream_channel] - webdriver 2.1.2 [archive matcher path stack_trace sync_http] - webkit_inspection_protocol 0.7.4 [logging] - win32 1.7.4 [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] ```

markusaksli-nc commented 3 years ago

Hi @davidbrenner I'm not seeing this on the latest master 1.26.0-13.0.pre.231 with firebase_messaging: ^8.0.0-dev.14 using the official example.

flutter doctor -v ```console [√] Flutter (Channel master, 1.26.0-13.0.pre.231, on Microsoft Windows [Version 10.0.19041.746], locale et-EE) β€’ Flutter version 1.26.0-13.0.pre.231 at C:\Development\flutter_master β€’ Framework revision 29e604e241 (2 hours ago), 2021-01-28 00:04:03 -0800 β€’ Engine revision 68cd4c42b5 β€’ Dart version 2.12.0 (build 2.12.0-267.0.dev) [√] Android toolchain - develop for Android devices (Android SDK version 30.0.2) β€’ Android SDK at C:\Users\marku\AppData\Local\Android\sdk β€’ Platform android-30, build-tools 30.0.2 β€’ Java binary at: C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\201.7042882\jre\bin\java β€’ Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01) β€’ All Android licenses accepted. [√] Chrome - develop for the web β€’ Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe [√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.7.7) β€’ Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Community β€’ Visual Studio Community 2019 version 16.7.30621.155 β€’ Windows 10 SDK version 10.0.18362.0 [√] Android Studio (version 4.1.0) β€’ Android Studio at C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-0\201.7042882 β€’ Flutter plugin can be installed from: https://plugins.jetbrains.com/plugin/9212-flutter β€’ Dart plugin can be installed from: https://plugins.jetbrains.com/plugin/6351-dart β€’ Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b01) [√] Connected device (4 available) β€’ SM G950F (mobile) β€’ ce12171c51cc001c03 β€’ android-arm64 β€’ Android 9 (API 28) β€’ Windows (desktop) β€’ windows β€’ windows-x64 β€’ Microsoft Windows [Version 10.0.19041.746] β€’ Chrome (web) β€’ chrome β€’ web-javascript β€’ Google Chrome 87.0.4280.141 β€’ Edge (web) β€’ edge β€’ web-javascript β€’ Microsoft Edge 87.0.664.75 β€’ No issues found! ```
I/flutter ( 7543): A new onMessageOpenedApp event was published!

What are you using to check that the callback has executed? Are there any errors logged? Thank you

kuromukira commented 3 years ago

Hi @markusaksli-nc , I am also experiencing this issue. onMessage and onMessageOpened handlers are not called. I have methods that are supposed to be triggered when a notification is received, but with v8.0.0-dev.14, they're are not called. I added debug outputs to the console just to verify if they were called, but no console output even with notifications received.

I was previously on the 7.0.3 version of firebase_messaging. But I need to be on v8.0.0-dev.14 to be compatible with the updates for the other firebase plugins. And also because notifications stopped being received for me on 7.0.3 using the legacy HTTP to push to FCM.

Flutter doctor

Run flutter doctor and paste the output below:

Click To Expand ``` [βœ“] Flutter (Channel stable, 1.22.6, on macOS 11.1 20C69 darwin-x64, locale en-PH) β€’ Flutter version 1.22.6 at /Users/mac/Documents/sdk/flutter β€’ Framework revision 9b2d32b605 (6 days ago), 2021-01-22 14:36:39 -0800 β€’ Engine revision 2f0af37152 β€’ Dart version 2.10.5 [βœ“] Android toolchain - develop for Android devices (Android SDK version 30.0.3) β€’ Android SDK at /Users/mac/Library/Android/sdk β€’ Platform android-30, build-tools 30.0.3 β€’ Java binary at: /Users/mac/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/201.6953283/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java β€’ Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495) β€’ All Android licenses accepted. [βœ“] Xcode - develop for iOS and macOS (Xcode 12.4) β€’ Xcode at /Applications/Xcode.app/Contents/Developer β€’ Xcode 12.4, Build version 12D4e β€’ CocoaPods version 1.10.1 [!] Android Studio (version 4.1) β€’ Android Studio at /Users/mac/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/201.6953283/Android Studio.app/Contents βœ— Flutter plugin not installed; this adds Flutter specific functionality. βœ— Dart plugin not installed; this adds Dart specific functionality. β€’ Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495) [βœ“] VS Code (version 1.52.1) β€’ VS Code at /Applications/Visual Studio Code.app/Contents β€’ Flutter extension version 3.18.1 [!] Connected device ! Error: iPHONE is not connected. Xcode will continue when iPHONE is connected. (code -13) ! Doctor found issues in 2 categories. ```

Flutter dependencies

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

Click To Expand ``` Dart SDK 2.10.5 Flutter SDK 1.22.6 nomnom 1.7.0 dependencies: - badges 1.1.6 [flutter] - bottom_navy_bar 5.6.0 [flutter] - bubble 1.1.9+1 [flutter] - cached_network_image 2.5.0 [flutter flutter_cache_manager octo_image] - camera 0.5.8+17 [flutter] - equatable 1.2.5 [collection meta] - fancy_on_boarding 1.7.0 [flutter flutter_svg] - file_picker 2.1.5+1 [flutter flutter_web_plugins flutter_plugin_android_lifecycle plugin_platform_interface] - firebase_analytics 7.0.1 [meta flutter firebase_core firebase_analytics_web firebase_analytics_platform_interface] - firebase_auth 0.20.0+1 [meta firebase_core firebase_core_platform_interface firebase_auth_platform_interface firebase_auth_web flutter] - firebase_core 0.7.0 [firebase_core_platform_interface flutter quiver meta firebase_core_web] - firebase_crashlytics 0.4.0+1 [flutter stack_trace firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface] - firebase_messaging 8.0.0-dev.14 [meta flutter firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web] - firebase_storage 7.0.0 [flutter firebase_core firebase_core_platform_interface firebase_storage_web firebase_storage_platform_interface quiver] - flip_card 0.4.4 [flutter] - flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine] - flutter_local_notifications 3.0.3 [flutter platform flutter_local_notifications_platform_interface timezone] - flutter_spinkit 4.1.2+1 [flutter] - flutter_splash 1.0.1 [flutter] - flutter_svg 0.19.1 [flutter meta path_drawing vector_math xml] - font_awesome_flutter 8.11.0 [flutter] - get_it 5.0.6 [async meta] - hive 1.4.4+1 [meta crypto] - hive_flutter 0.3.1 [flutter hive path_provider path] - http 0.12.2 [http_parser path pedantic] - intl 0.16.1 [path] - loading_overlay 0.2.1 [flutter] - logger 0.9.4 - otp_text_field 1.0.2 [flutter] - page_transition 1.1.7+6 [flutter] - path 1.8.0-nullsafety.1 - path_provider 1.6.27 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows] - provider 4.3.3 [collection flutter nested] - pull_to_refresh 1.6.3 [flutter] - toggle_switch 0.1.8 [flutter] - tuple 1.0.3 [quiver] - url_launcher 5.7.10 [flutter url_launcher_platform_interface url_launcher_web url_launcher_linux url_launcher_macos url_launcher_windows] - validators 2.0.1 [vin_decoder] dev dependencies: - build_runner 1.10.9 [args async build build_config build_daemon build_resolvers build_runner_core code_builder collection crypto dart_style glob graphs http_multi_server io js logging meta mime path pedantic pool pub_semver pubspec_parse shelf shelf_web_socket stack_trace stream_transform timing watcher web_socket_channel yaml] - 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] - hive_generator 0.8.2 [build source_gen hive analyzer dartx] transitive dependencies: - _fe_analyzer_shared 12.0.0 [meta] - analyzer 0.40.6 [_fe_analyzer_shared args cli_util collection convert crypto glob meta package_config path pub_semver source_span watcher yaml] - archive 2.0.13 [crypto args path] - args 1.6.0 - asn1lib 0.6.5 - async 2.5.0-nullsafety.1 [collection] - basic_utils 2.6.3 [http logging json_annotation pointycastle asn1lib convert crypto] - boolean_selector 2.1.0-nullsafety.1 [source_span string_scanner] - build 1.5.0 [analyzer async convert crypto logging meta path glob] - build_config 0.4.2 [checked_yaml json_annotation meta path pubspec_parse yaml] - build_daemon 2.1.4 [built_collection built_value http_multi_server logging pedantic path pool shelf shelf_web_socket stream_transform watcher web_socket_channel] - build_resolvers 1.4.3 [analyzer build crypto graphs logging meta path package_config pool pub_semver] - build_runner_core 6.0.3 [async build build_config build_resolvers collection convert crypto glob graphs json_annotation logging meta path package_config pedantic pool timing watcher yaml] - built_collection 4.3.2 [collection quiver] - built_value 7.1.0 [built_collection collection fixnum quiver] - characters 1.1.0-nullsafety.3 - charcode 1.2.0-nullsafety.1 - checked_yaml 1.0.2 [json_annotation source_span yaml] - cli_util 0.2.0 [path] - clock 1.1.0-nullsafety.1 - code_builder 3.5.0 [built_collection built_value collection matcher meta] - collection 1.15.0-nullsafety.3 - convert 2.1.1 [charcode typed_data] - crypto 2.1.5 [collection convert typed_data] - dart_style 1.3.9 [analyzer args path source_span] - dartx 0.5.0 [collection path crypto characters time meta] - fake_async 1.2.0-nullsafety.1 [clock collection] - ffi 0.1.3 - file 5.2.1 [intl meta path] - firebase 7.3.0 [http http_parser js] - firebase_analytics_platform_interface 1.0.3 [flutter meta] - firebase_analytics_web 0.1.1 [flutter flutter_web_plugins firebase firebase_analytics_platform_interface meta] - firebase_auth_platform_interface 3.0.1 [flutter meta firebase_core plugin_platform_interface] - firebase_auth_web 0.3.2+6 [flutter flutter_web_plugins meta http_parser intl firebase_core firebase_core_web firebase_auth_platform_interface js] - firebase_core_platform_interface 3.0.1 [flutter meta plugin_platform_interface quiver] - firebase_core_web 0.2.1+3 [firebase_core_platform_interface flutter flutter_web_plugins meta js] - firebase_crashlytics_platform_interface 1.1.6 [flutter meta collection firebase_core plugin_platform_interface] - firebase_messaging_platform_interface 1.0.0-dev.10 [flutter meta firebase_core plugin_platform_interface] - firebase_messaging_web 0.1.0-dev.5 [flutter flutter_web_plugins meta firebase_core firebase_core_web firebase_messaging_platform_interface js service_worker] - firebase_storage_platform_interface 1.0.4 [flutter meta collection firebase_core plugin_platform_interface] - firebase_storage_web 0.1.1+3 [async crypto firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http js meta] - fixnum 0.10.11 - flutter_blurhash 0.5.0 [flutter meta] - flutter_cache_manager 2.1.0 [flutter path_provider uuid http path sqflite pedantic clock file rxdart image] - flutter_local_notifications_platform_interface 2.0.0+1 [flutter plugin_platform_interface] - flutter_plugin_android_lifecycle 1.0.11 [flutter] - flutter_web_plugins 0.0.0 [flutter characters collection meta typed_data vector_math] - glob 1.2.0 [async collection node_io path pedantic string_scanner] - graphs 0.2.0 - http_multi_server 2.2.0 [async] - http_parser 3.1.4 [charcode collection source_span string_scanner typed_data] - image 2.1.19 [archive xml meta] - io 0.3.4 [charcode meta path string_scanner] - js 0.6.2 - json_annotation 3.0.1 - 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] - node_interop 1.2.0 [js] - node_io 1.1.1 [node_interop path] - octo_image 0.3.0 [flutter flutter_blurhash] - package_config 1.9.3 [path charcode] - path_drawing 0.4.1+1 [vector_math meta path_parsing flutter] - path_parsing 0.1.4 [vector_math meta] - 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] - pointycastle 1.0.2 - pool 1.4.0 [async stack_trace] - process 3.0.13 [file intl meta path platform] - pub_semver 1.4.4 [collection] - pubspec_parse 0.1.5 [checked_yaml json_annotation pub_semver yaml] - quiver 2.1.3 [matcher meta] - random_string 2.1.0 - rxdart 0.24.1 - service_worker 0.2.4 [js] - shelf 0.7.9 [async collection http_parser path stack_trace stream_channel] - shelf_web_socket 0.2.3 [shelf web_socket_channel stream_channel] - sky_engine 0.0.99 - source_gen 0.9.8 [analyzer async build dart_style glob meta path pedantic source_span] - 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] - stream_transform 1.2.0 - 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] - time 1.3.0 - timezone 0.5.7 [path] - timing 0.1.1+2 [json_annotation] - typed_data 1.3.0-nullsafety.3 [collection] - url_launcher_linux 0.0.1+1 [flutter] - url_launcher_macos 0.0.1+8 [flutter] - url_launcher_platform_interface 1.0.9 [flutter meta plugin_platform_interface] - url_launcher_web 0.1.5 [url_launcher_platform_interface flutter flutter_web_plugins meta] - url_launcher_windows 0.0.1+1 [flutter] - uuid 2.2.2 [crypto convert] - vector_math 2.1.0-nullsafety.3 - vin_decoder 0.1.2 [meta basic_utils http random_string] - watcher 0.9.7+15 [async path pedantic] - web_socket_channel 1.1.0 [async crypto stream_channel] - 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] ```
markusaksli-nc commented 3 years ago

What could play a factor here is the transition to solely use APNs on iOS.

You should carefully check that you have done everything here https://firebase.flutter.dev/docs/messaging/apple-integration

kuromukira commented 3 years ago

I have followed the steps here https://firebase.flutter.dev/docs/messaging/apple-integration/. I also followed the migration guide from 7.0.3 to 8.0.0-dev.14

I also ended up doing it twice just to make sure. But same the behaviour, no notifications received.

davidbrenner commented 3 years ago

I am in the same boat as @kuromukira - I've double checked all of the steps in the migration and integration guides. Looking through the issues in this repository, there seem to be quite a few others that are facing this issue.

@markusaksli-nc - is there something else we should be checking? Can you perhaps try replicating this issue on a project built with firebase-cloud-messaging 7.0.3 and an older version of flutter, then following the upgrade process and pointing out where we're going wrong?

I'd be happy to do this myself, but I am not making much progress over the past few days trying to debug this issue. Some more direction would be appreciated, as there appears to be something broken in the upgrade path.

markusaksli-nc commented 3 years ago

Are you sure that it is an issue with the upgrade path?

Could you try setting up a flutter create --org com.mycompany messagingproject project and see if the official code example works in it?

davidbrenner commented 3 years ago

@markusaksli-nc Yes, working through this now. Right off the bat, the documentation and/or pubspec requirements have an issue:

My pubspec.yaml (via https://firebase.flutter.dev/docs/messaging/overview):

dependencies:
  flutter:
    sdk: flutter
  firebase_core: "^0.8.0-nullsafety.1"
  firebase_messaging: "^8.0.0-dev.14"
$ flutter pub get
Running "flutter pub get" in messagingproject...                
Because firebase_messaging >=8.0.0-dev.13 depends on firebase_core ^0.7.0 and messagingproject depends on firebase_core ^0.8.0-nullsafety.1, firebase_messaging >=8.0.0-dev.13 is forbidden.

So, because messagingproject depends on firebase_messaging ^8.0.0-dev.14, version solving failed.
pub get failed (1; So, because messagingproject depends on firebase_messaging ^8.0.0-dev.14, version solving failed.)
exit code 

Setting firebase_core to 0.7.0 and proceeding from there.

kuromukira commented 3 years ago

@markusaksli-nc @davidbrenner

I was able to finally make it work on an IOS device by recreating my APNS keys in Apple Developer and adding it again in Firebase Console. Seems weird tho that it worked that way since my original APNS key was just 4 months old and was working for a good 4 months.

davidbrenner commented 3 years ago

@kuromukira - interesting, thanks for sharing. It is still not working for me, unfortunately. The app I had created for testing, I created a new APN key for. I still have both associated with my Firebase account, but for different apps. Neither app is triggering the onMessage or onMessageOpenedApp callbacks.

kuromukira commented 3 years ago

@davidbrenner what are you using to send the messages? Firebase Console, legacy HTTP, HTTP v1 or admin sdk? I made mine work using Admin SDK (in C#). I was originally using the legacy HTTP approach but it stopped (hence my upgrade to 8.0.0-dev.14 and encountering this issue).

ChristianConstantNel commented 3 years ago

@kuromukira Is there any addition setup that needs to be done on IOS for it to receive the message? I've got it working on Android, but can't seem to receive the notification on IOS.

I've done the following:

  1. Create APNs Auth Key and added it to Firebase.
  2. Added Push Notifications and BackGround Modes (Fetch and Notifications) capabilities to my Xcode project.
  3. On IOS asked for permissions
  4. Set the ForegroundNotificationPresentationOptions too true for; alert badge and sound.

I'm sending the message via the Firebase Console, but I cannot get it to work. If anyone has any tips I would greatly appreciate it. Been searching for hours without a solution.

markusaksli-nc commented 3 years ago

@davidbrenner That is strange. Since it didn't work in the new project either there has to be something up with the setup. I just tried it again and everything works for me. Glad to hear that @kuromukira was able to solve it as well.

A dumb question but you are using the same package identifier for the app as for the provisioning profile with push notifications?

@ChristianConstantNel Same question to you. It's a bit hard to diagnose these failures since we can't really know what link in the chain is failing due to no error logs or messages.

Either of you aren't seeing anything relevant logged in flutter run -v or Xcode console?

ChristianConstantNel commented 3 years ago

@markusaksli-nc Thanks for the response. I don't see any options to set the package identifier for the APNs Key. Should I rather create an APNs certificate and use that instead of the key?

markusaksli-nc commented 3 years ago

I meant the package identifier you use for the provisioning profile with push notifications.

ChristianConstantNel commented 3 years ago

@markusaksli-nc Just double checked, and yes they are the same.

I'm I correct in saying that the only thing needed for IOS is to create a APN key, upload it to firebase, Add the correct capabilities to the Xcode project and ask for permission on IOS?

Is there nothing else to setup? No onResume or Configure etc?

markusaksli-nc commented 3 years ago

If by nothing else you mean you just need to register callbacks for the events in the code then yes (see https://github.com/FirebaseExtended/flutterfire/blob/master/packages/firebase_messaging/firebase_messaging/example/lib/main.dart)

There is the small matter of what exactly you are using to send the notification and what is the payload.

ChristianConstantNel commented 3 years ago

Thank you, I'll have a look at the example to make sure I'm doing the callbacks correctly.

davidbrenner commented 3 years ago

~I got it working.~

@markusaksli-nc - I didn't realize I should be using example code from the package, and instead was trying to piece it together from the documentation. Swapping out my code for the code in https://github.com/FirebaseExtended/flutterfire/blob/master/packages/firebase_messaging/firebase_messaging/example/lib/main.dart did get it working.

~Reviewing my code in more detail to see what I did that was different/incorrect, I did find that swapping out where await Firebase.initializeApp() is called to be in the main() entry point before runApp() solved the issue for me. In my code, I was calling this based on the StatefulWidget example provided at https://firebase.flutter.dev/docs/overview which did not work for me. It's not at all obvious to me why that wouldn't work, but as I said, swapping out where initializeApp() is called did the trick for me. Everything is now working as expected.~

Here's my code to hopefully help anyone else struggling with this:

Click To Expand and see example code ``` import 'package:flutter/material.dart'; import 'package:firebase_core/firebase_core.dart'; import 'package:firebase_messaging/firebase_messaging.dart'; void main() async { WidgetsFlutterBinding.ensureInitialized(); await Firebase.initializeApp(); runApp(App()); } class App extends StatefulWidget { _AppState createState() => _AppState(); } class _AppState extends State { // Set default `_initialized` and `_error` state to false bool _initialized = false; bool _error = false; // Define an async function to initialize FlutterFire Future initializeFlutterFire() async { try { // Wait for Firebase to initialize and set `_initialized` state to true // DO NOT INITIALIZE HERE - This did not work for me. Instead initialize in main() //await Firebase.initializeApp(); await initFirebaseMessaging(); setState(() { _initialized = true; }); } catch(e) { // Set `_error` state to true if Firebase initialization fails print(e); setState(() { _error = true; }); } } Future saveTokenToDatabase(String token) async { // Assume user is logged in for this example /* String userId = FirebaseAuth.instance.currentUser.uid; await FirebaseFirestore.instance .collection('users') .doc(userId) .update({ 'tokens': FieldValue.arrayUnion([token]), }); */ print('FCM token: $token'); } Future initFirebaseMessaging() async { RemoteMessage initialMessage = await FirebaseMessaging.instance.getInitialMessage(); // If the message also contains a data property with a "type" of "chat", // navigate to a chat screen if (initialMessage != null && initialMessage?.data['type'] == 'chat') { print("Got initial message $initialMessage"); } FirebaseMessaging.onMessage.listen((RemoteMessage message) { print("Got message $message"); }); // Also handle any interaction when the app is in the background via a // Stream listener FirebaseMessaging.onMessageOpenedApp.listen((RemoteMessage message) { print("Got message opened app $message"); }); String token = await FirebaseMessaging.instance.getToken(); // Save the initial token to the database await saveTokenToDatabase(token); // Any time the token refreshes, store this in the database too. FirebaseMessaging.instance.onTokenRefresh.listen(saveTokenToDatabase); } @override void initState() { super.initState(); initializeFlutterFire(); } @override Widget build(BuildContext context) { // Show error message if initialization failed if(_error) { return MaterialApp( home: Scaffold(body: Center(child: Container(child: Text("Something went wrong"))))); } // Show a loader until FlutterFire is initialized if (!_initialized) { return MaterialApp(home: Scaffold(body: Center(child: Container(child: Text("Loading.."))))); } return MaterialApp(home: Scaffold(body: Center(child: Container(child: Text("My Awesome App"))))); } } ```

And, I have been using curl and the legacy API to send the notification:

curl -H "Content-type: application/json" -H "Authorization:key=<API KEY>"  -X POST -d '{ "notification": { "title": "Test","body": "notification"},"to" : "<DEVICE TOKEN>", "content-available": true, "data": {"test": "this is a test"}, "priority": "high"}' https://fcm.googleapis.com/fcm/send

~I'd very much recommend changing the FlutterFire documentation to recommend initializing in main() before runApp() if it is indeed required for firebase-messaging (and potentially other libraries). I would submit a PR for that, but I am not sure how to correctly translate the existing to code to pass down error state into the App/widget.~

markusaksli-nc commented 3 years ago

Wait was the only difference that Firebase.initializeApp() was not in main?

@davidbrenner Could you provide a code sample of the non-working app just to make sure something isn't actually broken. If that was the only difference I don't know why it wouldn't work.

davidbrenner commented 3 years ago

Ah, thanks for pointing that out - that was not the only difference. I hadn't uninstalled the non-working app in between switching from the example code and incorrectly attributed it working to the first change I made. In haste, I didn't realize I had not requested notification permissions in my app.

Let me go back to my main app to see if I can uncover the issue there.

markusaksli-nc commented 3 years ago

I'll optimistically close this as solved for now but let me know if there was anything relevant and I'll reopen

Kurogoma4D commented 3 years ago

Hi @markusaksli-nc , I faced same issue, and ran FlutterFire example project with my Apple Developer account and Firebase project.

As a result, it doesn't work on Flutter stable channel (v1.22.6). Then, I changed Flutter channel to master(v1.26.0-18.0.pre.90), it worked perfectly.

So, I think this issue is Flutter version related. But is this right (or expected) dependencies? Thanks.

Kurogoma4D commented 3 years ago

So, I think this issue is Flutter version related. But is this right (or expected) dependencies?

This is my misunderstanding... I created a new minimal project with stable channel, and it worked. never mind🀦

davidbrenner commented 3 years ago

I am still struggling with this for our production app. The sample app works fine, but I've had no luck making those same changes in our app.

I am able to receive notifications and they open the app, but our onMessage and onMessageOpenedApp are not being triggered.

davidbrenner commented 3 years ago

@markusaksli-nc - can you reopen this and possibly provide some additional steps to consider?

markusaksli-nc commented 3 years ago

I'm not sure how to move further with this one since we still aren't seeing this with the official example. Could you provide a minimal complete reproducible code sample of how you are using the streams exactly exactly?

davidbrenner commented 3 years ago

Hi @markusaksli-nc - you can close this. Thanks for your patience and help.

The problem appears to have been OneSignal. It was working alongside FCM without issues on previous versions of our app, but it seems one of the changes in flutter, OneSignal's flutter plugin, or FCM's flutter plugin/SDK broke their interoperability. It seems like OneSignal's SDK is grabbing all the messages before they make it to FCM.

I've opened a bug with OneSignal for them to investigate further, but removing OneSignal from the project makes FCM's notification handling within Dart work again.