Skip to content

🐛 [Firebase_messaging 8.0.0-dev.8] 'onLaunch' not showing the notification #4096

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
evripidesk opened this issue Nov 11, 2020 · 7 comments
Labels
Needs Attention This issue needs maintainer attention. type: bug Something isn't working

Comments

@evripidesk
Copy link

Hello

I migrated to the new firebase messaging 8.0.0 dev8 i tried it and is working but I have issue when notification received and the application is killed and user click on notification not showing the message , in the case that the app is in the backround is working fine the issue is only 'onLaunch'

fcm.FirebaseMessaging.onMessageOpenedApp.listen((message) {
      print('Got a message whilst in the foreground!');
      print('Message data: ${message.data}');
      print(message.data['extraPayLoad1']);

});
@evripidesk evripidesk added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Nov 11, 2020
@markusaksli-nc
Copy link
Contributor

Hi @evripidesk
Could you explain a bit more what is the expected vs actual behavior here? Using the official example on the latest flutter master 1.24.0-8.0.pre.208 and firebase_messaging: ^8.0.0-dev.8 the onMessageOpenedApp callback works just fine if the app is in background or killed.

flutter doctor -v
[√] Flutter (Channel master, 1.24.0-8.0.pre.208, on Microsoft Windows [Version 10.0.19041.572], locale et-EE)
    • Flutter version 1.24.0-8.0.pre.208 at C:\Development\flutter_master
    • Framework revision 15d2d8a875 (8 hours ago), 2020-11-11 20:04:03 -0500
    • Engine revision d97a81c889
    • Dart version 2.12.0 (build 2.12.0-31.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.6953283\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.6953283
    • 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)

[√] IntelliJ IDEA Ultimate Edition (version 2020.2)
    • IntelliJ at C:\Users\marku\AppData\Local\JetBrains\Toolbox\apps\IDEA-U\ch-0\202.7660.26
    • 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

[√] Connected device (6 available)
    • SM G950F (mobile)           • ce12171c51cc001c03 • android-arm64  • Android 9 (API 28)
    • sdk gphone x86 arm (mobile) • emulator-5554      • android-x86    • Android 11 (API 30) (emulator)
    • Windows (desktop)           • windows            • windows-x64    • Microsoft Windows [Version 10.0.19041.572]
    • Web Server (web)            • web-server         • web-javascript • Flutter Tools
    • Chrome (web)                • chrome             • web-javascript • Google Chrome 86.0.4240.183
    • Edge (web)                  • edge               • web-javascript • Microsoft Edge 86.0.622.63

• No issues found!

Based on your print statements maybe you meant the onMessage callback?
Could you also please provide your flutter doctor -v and flutter pub deps -- --style=compact? Is this on android or iOS?

Thank you

@markusaksli-nc markusaksli-nc added blocked: customer-response Waiting for customer response, e.g. more information was requested. and removed Needs Attention This issue needs maintainer attention. labels Nov 12, 2020
@evripidesk
Copy link
Author

evripidesk commented Nov 12, 2020

I have the below code

  void initState() {
...
fcm.FirebaseMessaging.onMessageOpenedApp.listen((message) {
      print('Got a message whilst in the foreground!');
      print('Message data: ${message.data}');
      print(message.data['extraPayLoad1']);
          _showItemDialog2(message.data);
});
fcm.FirebaseMessaging.onMessage.listen((fcm.RemoteMessage message) {
      print('Got a message whilst in the foreground!');
      print('Message data: ${message.data}');
          _showItemDialog2(message.data);

});

}

When I am on foreground the _showItemDialog2(message.data) called successful when I am on background the notification come to notification tray I click on notification and the _showItemDialog2(message.data) called successful but when the app is killed the notification come to notification tray I click on notification the app open but the _showItemDialog2(message.data) is not call

I tried it on android and iOS (real devices)

flutter doctor -v
[✓] Flutter (Channel stable, 1.22.3, on Mac OS X 10.15.7 19H15, locale en-GB)
    • Flutter version 1.22.3 at /Users/mac/development/flutter
    • Framework revision 8874f21e79 (2 weeks ago), 2020-10-29 14:14:35 -0700
    • Engine revision a1440ca392
    • Dart version 2.10.3

 
[✓] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
    • Android SDK at /Users/mac/Library/Android/sdk
    • Platform android-29, build-tools 29.0.2
    • ANDROID_HOME = /usr/local/share/android-sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.1, Build version 12A7403
    • CocoaPods version 1.9.3

[✓] Android Studio (version 3.5)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 44.0.1
    • Dart plugin version 191.8593
    • Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)

[✓] VS Code (version 1.51.0)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.16.0

 
[!] Connected device                          
    ! No devices available

! Doctor found issues in 1 category
flutter pub deps -- --style=compact
Dart SDK 2.10.3
Flutter SDK 1.22.3
remindme 1.0.3+40

dependencies:
- assets_audio_player 2.0.13+1 [flutter rxdart uuid http path_provider assets_audio_player_web]
- autocomplete_textfield 1.7.3 [flutter]
- badges 1.1.4 [flutter]
- cached_network_image 2.3.3 [flutter flutter_cache_manager octo_image]
- confetti 0.5.4+1 [flutter random_color vector_math]
- contacts_service 0.4.6 [flutter collection quiver]
- cupertino_icons 0.1.3
- expandable_bottom_bar 1.0.2 [flutter]
- firebase_core 0.5.2 [firebase_core_platform_interface flutter quiver meta firebase_core_web]
- firebase_messaging 8.0.0-dev.8 [meta flutter firebase_core firebase_core_platform_interface firebase_messaging_platform_interface]
- flare_flutter 2.0.6 [flutter flare_dart meta]
- flutter 0.0.0 [characters collection meta typed_data vector_math sky_engine]
- flutter_animator 2.1.0 [flutter vector_math]
- flutter_app_badger 1.1.2 [flutter]
- flutter_datetime_picker 1.4.0 [flutter]
- flutter_launcher_icons 0.8.1 [image args yaml path]
- flutter_local_notifications 1.5.0+1 [flutter platform flutter_local_notifications_platform_interface]
- flutter_native_timezone 1.0.4 [flutter]
- flutter_offline 0.3.0 [flutter connectivity]
- flutter_sim_country_code 0.0.3 [flutter]
- flutter_slidable 0.5.7 [flutter]
- flutter_spinkit 4.1.2+1 [flutter]
- flutter_typeahead 1.8.8 [flutter flutter_keyboard_visibility]
- flutter_web_browser 0.11.0 [flutter]
- flutter_widgetkit 1.0.1 [flutter]
- http 0.12.2 [http_parser path pedantic]
- image_picker 0.6.7+12 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface]
- in_app_purchase 0.3.4+16 [async collection flutter json_annotation meta]
- intl 0.16.1 [path]
- intro_slider 2.3.3 [flutter]
- jiffy 3.0.1 [intl]
- mime 0.9.7
- modal_bottom_sheet 0.2.2 [flutter]
- package_info 0.4.3+2 [flutter]
- path_provider 1.6.24 [flutter path_provider_platform_interface path_provider_macos path_provider_linux path_provider_windows]
- permission_handler 5.0.1+1 [flutter meta permission_handler_platform_interface]
- purchases_flutter 1.4.3 [flutter]
- rflutter_alert 1.1.0 [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]
- showcaseview 0.1.6 [flutter]
- simple_animations 2.2.3 [flutter sa_multi_tween sa_anicoto sa_stateless_animation sa_v1_migration]
- sliding_up_panel 1.0.2 [flutter]
- sqflite 1.3.2+1 [flutter sqflite_common path]
- timezone 0.5.9 [path]
- url_launcher 5.7.10 [flutter url_launcher_platform_interface url_launcher_web url_launcher_linux url_launcher_macos url_launcher_windows]
- web_socket_channel 1.1.0 [async crypto stream_channel]

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
- assets_audio_player_web 2.0.13+1 [flutter flutter_web_plugins]
- 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
- connectivity 0.4.9+5 [flutter meta connectivity_platform_interface connectivity_macos connectivity_for_web]
- 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]
- 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.0.0 [flutter meta plugin_platform_interface quiver]
- firebase_core_web 0.2.1 [firebase_core_platform_interface flutter flutter_web_plugins meta js]
- firebase_messaging_platform_interface 1.0.0-dev.5 [flutter meta firebase_core plugin_platform_interface]
- flare_dart 2.3.4
- flutter_blurhash 0.5.0 [flutter meta]
- flutter_cache_manager 2.0.0 [flutter path_provider uuid http path sqflite pedantic clock file rxdart]
- flutter_keyboard_visibility 3.3.0 [flutter]
- flutter_local_notifications_platform_interface 1.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]
- http_parser 3.1.4 [charcode collection source_span string_scanner typed_data]
- image 2.1.18 [archive xml meta]
- image_picker_platform_interface 1.1.1 [flutter meta http plugin_platform_interface]
- js 0.6.2
- json_annotation 3.1.0
- matcher 0.12.10-nullsafety.1 [stack_trace]
- meta 1.3.0-nullsafety.3
- 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+6 [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.9.2 [meta]
- permission_handler_platform_interface 2.0.1 [flutter meta plugin_platform_interface]
- 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]
- quiver 2.1.5 [matcher meta]
- random_color 1.0.5 [flutter]
- rxdart 0.24.1
- sa_anicoto 1.0.3 [flutter supercharged]
- sa_multi_tween 1.1.3 [flutter supercharged]
- sa_stateless_animation 1.0.3 [flutter supercharged sa_anicoto]
- sa_v1_migration 1.1.2 [flutter]
- 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_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]
- supercharged 1.11.1 [supercharged_dart flutter]
- supercharged_dart 1.3.1
- 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_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
- 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]

@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 Nov 12, 2020
@paynekw
Copy link

paynekw commented Nov 12, 2020

@evripidesk If you look at the implementation of onMessageOpenedApp you will see the following:

/// A Stream event will be sent if the app has opened from a background state
/// (not terminated).
///
/// If your app is opened via a notification whilst the app is terminated,
/// see [getInitialMessage].
static Stream<RemoteMessage> get onMessageOpenedApp {
...

@paynekw
Copy link

paynekw commented Nov 12, 2020

@evripidesk please share the iOS version running on your iPhone.

@evripidesk
Copy link
Author

@paynekw I will try the

    messaging.getInitialMessage().then((message) {

iOS version 14.2

@evripidesk
Copy link
Author

thank you this is working fine

messaging.getInitialMessage().then((message) {

tested on iOS 14.2 and android

@markusaksli-nc
Copy link
Contributor

Closing this based on your last message, glad you solved it and thanks for the helpful comment @paynekw

@firebase firebase locked and limited conversation to collaborators Dec 14, 2020
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. type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants