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

🐛 [firebase_messaging] getInitialMessage returning incorrect data #12453

Open keithcwk opened 8 months ago

keithcwk commented 8 months ago

Bug report

Describe the bug When the app is launched from a cold start scenario, getInitialMessage is called, however, the value of initialMessage is null in majority of the cases

In my application, getInitialMessage is used to provide a path to redirect to, located in initialMessage.data. However, when logging the value of initialMessage.data, there are multiple instances where it is logged as null

This causes the redirect from push notification feature to be quite unusable, and our app is facing this issue on production.

Steps to reproduce

Steps to reproduce the behavior:

  1. Ensure that await FirebaseMessaging.instance.getInitialMessage is in the initState of main.dart
  2. Add print statement to print the contents of getInitialMessage
  3. Send a notification to the device with data
  4. Click on the notification

Expected behavior

The value of initialMessage returns data of initialMessage that was recently consumed

Sample project


Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(
    options: DefaultFirebaseOptions.currentPlatform,
  );

  runApp(
    const ProviderScope(
      child: MyApp(),
    ),
  );
}

class MyApp extends ConsumerStatefulWidget {
  const MyApp({
    super.key,
  });
  @override
  MyAppState createState() => MyAppState();
}

class MyAppState extends ConsumerState<MyApp> {
  Future<void> handleNotificationData() async {
    RemoteMessage? initialMessage =
        await FirebaseMessaging.instance.getInitialMessage();

    Logger.logFuncValues(LoggerKeys.handleNotifData, initialMessage?.data);

    if (initialMessage?.data['path'] != null) {
      Logger.logFuncStart(LoggerKeys.onInitialMessage);
      redirect(initialMessage?.data['path']);
    }

    FirebaseMessaging.onMessageOpenedApp.listen(
      (RemoteMessage message) async {
        Logger.logFuncValues(LoggerKeys.onMessageOpenedApp, message.data);

        redirect(message.data['path']);
      },
    );
  }

  @override
  void initState() {
    handleNotificationData();

    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return const Directionality(
      textDirection: TextDirection.ltr,
      child: Scaffold(
        body: Center(child: Text('test')),
      ),
    );
  }
}

Additional context

Appreciate the effort in reading this report and I hope that this can be fixed


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, 3.19.2, on macOS 14.1.1 23B81 darwin-arm64, locale en-MY) [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) [✓] Xcode - develop for iOS and macOS (Xcode 15.2) [✓] Chrome - develop for the web [✓] Android Studio (version 2020.3) [✓] VS Code (version 1.87.1) [✓] Connected device (3 available) ! Error: Browsing on the local area network for Keith’s Apple Watch. Ensure the device is unlocked and discoverable via Bluetooth. (code -27) ! Error: Browsing on the local area network for Keith’s iPhone. Ensure the device is unlocked and attached with a cable or associated with the same local area network as this Mac. The device must be opted into Developer Mode to connect wirelessly. (code -27) [✓] Network resources • No issues found! ```

Flutter dependencies

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

Click To Expand ``` Dart SDK 3.3.0 Flutter SDK 3.19.2 app 1.47.0+403 dependencies: - advertising_id 2.5.0 [flutter] - android_play_install_referrer 0.3.0 [flutter] - app_settings 5.1.1 [flutter plugin_platform_interface] - app_tracking_transparency 2.0.4 [flutter] - appsflyer_sdk 6.12.2 [flutter] - cached_network_image 3.3.1 [cached_network_image_platform_interface cached_network_image_web flutter flutter_cache_manager octo_image] - cloud_firestore 4.13.3 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta] - collection 1.18.0 - connectivity_plus 3.0.6 [flutter flutter_web_plugins connectivity_plus_platform_interface js meta nm] - cupertino_will_pop_scope 1.2.1 [flutter] - device_info_plus 9.1.1 [device_info_plus_platform_interface ffi file flutter flutter_web_plugins meta win32 win32_registry] - equatable 2.0.5 [collection meta] - expandable_text 2.3.0 [flutter] - extended_image 8.2.0 [extended_image_library flutter meta] - extended_nested_scroll_view 6.1.2 [flutter visibility_detector] - extended_text 13.0.0 [extended_text_library flutter] - firebase_analytics 10.8.0 [firebase_analytics_platform_interface firebase_analytics_web firebase_core firebase_core_platform_interface flutter] - firebase_app_check 0.2.1+6 [firebase_app_check_platform_interface firebase_app_check_web firebase_core firebase_core_platform_interface flutter] - firebase_auth 4.16.0 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 2.24.2 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_crashlytics 3.4.9 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace] - firebase_messaging 14.7.10 [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_animate 4.3.0 [flutter] - flutter_app_badger 1.5.0 [flutter] - flutter_facebook_auth 6.0.3 [flutter flutter_facebook_auth_platform_interface flutter_facebook_auth_web facebook_auth_desktop] - flutter_html 3.0.0-beta.2 [html csslib collection list_counter flutter] - flutter_localizations 0.0.0 [flutter intl characters clock collection material_color_utilities meta path vector_math] - flutter_markdown 0.6.18+2 [flutter markdown meta path] - flutter_native_splash 2.3.6 [args flutter flutter_web_plugins js html image meta path universal_io xml yaml ansicolor] - flutter_rating_bar 4.0.1 [flutter] - flutter_riverpod 2.4.9 [collection flutter meta riverpod state_notifier] - flutter_secure_storage 9.0.0 [flutter flutter_secure_storage_linux flutter_secure_storage_macos flutter_secure_storage_platform_interface flutter_secure_storage_web flutter_secure_storage_windows meta] - flutter_svg 2.0.9 [flutter vector_graphics vector_graphics_codec vector_graphics_compiler] - fluttertoast 8.2.4 [flutter flutter_web_plugins] - freezed_annotation 2.4.1 [collection json_annotation meta] - go_router 12.1.1 [collection flutter flutter_web_plugins logging meta] - google_fonts 6.2.1 [flutter http path_provider crypto] - google_sign_in 6.1.6 [flutter google_sign_in_android google_sign_in_ios google_sign_in_platform_interface google_sign_in_web] - graphql 5.2.0-beta.1 [meta path gql gql_exec gql_link gql_http_link gql_transform_link gql_error_link gql_dedupe_link hive normalize http collection web_socket_channel stream_channel rxdart uuid] - graphql_flutter 5.2.0-beta.1 [graphql gql_exec flutter meta path_provider path connectivity_plus hive plugin_platform_interface flutter_hooks] - hive 2.2.3 [meta crypto] - intl 0.18.1 [clock meta path] - ionicons 0.2.2 [flutter] - keframe 3.0.0 [flutter] - lazy_load_indexed_stack 1.0.1 [flutter] - lottie 2.7.0 [archive flutter path vector_math] - mailto 2.0.0 - mixpanel_flutter 2.2.0 [flutter flutter_web_plugins js] - move_to_background 1.0.2 [flutter] - package_info_plus 4.1.0 [ffi flutter flutter_web_plugins http meta path package_info_plus_platform_interface win32] - path_provider 2.1.1 [flutter path_provider_android path_provider_foundation path_provider_linux path_provider_platform_interface path_provider_windows] - permission_handler 11.1.0 [flutter meta permission_handler_android permission_handler_apple permission_handler_html permission_handler_windows permission_handler_platform_interface] - photo_view 0.14.0 [flutter] - preload_page_view 0.2.0 [flutter] - rate_my_app 2.0.0 [shared_preferences flutter_rating_bar flutter] - screenshot 2.1.0 [flutter] - scrollview_observer 1.18.2 [flutter] - share_plus 7.2.1 [cross_file meta mime flutter flutter_web_plugins share_plus_platform_interface file url_launcher_web url_launcher_windows url_launcher_linux url_launcher_platform_interface ffi win32] - shared_preferences 2.2.2 [flutter shared_preferences_android shared_preferences_foundation shared_preferences_linux shared_preferences_platform_interface shared_preferences_web shared_preferences_windows] - sign_in_with_apple 5.0.0 [flutter meta sign_in_with_apple_platform_interface sign_in_with_apple_web] - sliver_tools 0.2.12 [flutter] - social_share 2.3.1 [flutter path_provider] - talker_flutter 4.0.2 [flutter talker group_button path_provider share_plus] - time 2.1.3 [clock] - timeago 3.6.0 [intl] - upgrader 9.0.0 [flutter device_info_plus html google_fonts google_api_availability http os_detect package_info_plus shared_preferences url_launcher version xml] - url_launcher 6.2.5 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows] - visibility_detector 0.4.0+2 [flutter] - webview_flutter 4.7.0 [flutter webview_flutter_android webview_flutter_platform_interface webview_flutter_wkwebview] - youtube_player_iframe 5.1.1 [flutter meta webview_flutter webview_flutter_android webview_flutter_wkwebview url_launcher youtube_player_iframe_web] dev dependencies: - analyzer 5.13.0 [_fe_analyzer_shared collection convert crypto glob meta package_config path pub_semver source_span watcher yaml] - artemis 7.13.0-beta.2 [build_config code_builder build collection dart_style equatable glob gql_code_builder gql_dedupe_link gql_exec gql_http_link gql_link gql http json_annotation path recase source_gen yaml] - build_runner 2.4.6 [analyzer args async build build_config build_daemon build_resolvers build_runner_core code_builder collection crypto dart_style frontend_server_client glob graphs http_multi_server io js logging meta mime package_config path pool pub_semver pubspec_parse shelf shelf_web_socket stack_trace stream_transform timing watcher web_socket_channel yaml] - custom_lint 0.5.7 [analyzer analyzer_plugin args async ci cli_util collection freezed_annotation json_annotation meta package_config path pub_semver pubspec_parse rxdart uuid yaml] - flutter_launcher_icons 0.13.1 [args checked_yaml cli_util image json_annotation path yaml] - flutter_lints 3.0.1 [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] - freezed 2.4.5 [analyzer build build_config collection meta source_gen freezed_annotation json_annotation] - hive_generator 2.0.1 [build source_gen hive analyzer source_helper] - json_serializable 6.7.1 [analyzer async build build_config collection json_annotation meta path pub_semver pubspec_parse source_gen source_helper] - riverpod_lint 2.1.1 [analyzer analyzer_plugin collection custom_lint_builder meta path riverpod riverpod_analyzer_utils source_span yaml] dependency overrides: - group_button 5.3.4 [flutter] - html 0.15.4 [csslib source_span] - http 1.1.0 [async http_parser meta] - web 0.5.0 transitive dependencies: - _fe_analyzer_shared 61.0.0 [meta] - _flutterfire_internals 1.3.16 [collection firebase_core firebase_core_platform_interface flutter meta] - analyzer_plugin 0.11.2 [analyzer collection dart_style pub_semver yaml] - ansicolor 2.0.2 - archive 3.4.9 [crypto path pointycastle] - args 2.4.2 - async 2.11.0 [collection meta] - boolean_selector 2.1.1 [source_span string_scanner] - build 2.4.1 [analyzer async convert crypto glob logging meta package_config path] - build_config 1.1.1 [checked_yaml json_annotation path pubspec_parse yaml] - build_daemon 4.0.0 [built_collection built_value http_multi_server logging path pool shelf shelf_web_socket stream_transform watcher web_socket_channel] - build_resolvers 2.3.1 [analyzer async build collection convert crypto graphs logging package_config path pool pub_semver stream_transform yaml] - build_runner_core 7.2.10 [async build build_config build_resolvers collection convert crypto glob graphs json_annotation logging meta package_config path pool timing watcher yaml] - built_collection 5.1.1 - built_value 8.6.2 [built_collection collection fixnum meta] - cached_network_image_platform_interface 4.0.0 [flutter flutter_cache_manager] - cached_network_image_web 1.1.1 [cached_network_image_platform_interface flutter flutter_cache_manager] - characters 1.3.0 - checked_yaml 2.0.3 [json_annotation source_span yaml] - ci 0.1.0 - cli_util 0.4.0 [meta path] - clock 1.1.1 - cloud_firestore_platform_interface 6.0.7 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - cloud_firestore_web 3.8.7 [_flutterfire_internals cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins js] - code_builder 4.6.0 [built_collection built_value collection matcher meta] - connectivity_plus_platform_interface 1.2.4 [flutter meta plugin_platform_interface] - convert 3.1.1 [typed_data] - cross_file 0.3.3+5 [js meta] - crypto 3.0.3 [typed_data] - csslib 0.17.3 [source_span] - custom_lint_builder 0.5.7 [analyzer analyzer_plugin collection custom_lint custom_lint_core glob hotreloader meta path pubspec_parse rxdart] - custom_lint_core 0.5.7 [analyzer analyzer_plugin collection custom_lint matcher meta path pubspec_parse source_span yaml] - dart_style 2.3.2 [analyzer args path pub_semver source_span] - dbus 0.7.8 [args ffi meta xml] - device_info_plus_platform_interface 7.0.0 [flutter meta plugin_platform_interface] - extended_image_library 4.0.1 [crypto flutter http_client_helper js path path_provider web] - extended_text_library 12.0.0 [flutter] - facebook_auth_desktop 1.0.2 [flutter http flutter_secure_storage flutter_facebook_auth_platform_interface] - fake_async 1.3.1 [clock collection] - ffi 2.1.0 - file 6.1.4 [meta path] - firebase_analytics_platform_interface 3.9.0 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_analytics_web 0.5.5+12 [_flutterfire_internals firebase_analytics_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - firebase_app_check_platform_interface 0.1.0+8 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_app_check_web 0.1.0+8 [_flutterfire_internals firebase_app_check_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - firebase_auth_platform_interface 7.0.9 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 5.8.13 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser js meta] - firebase_core_platform_interface 5.0.0 [collection flutter flutter_test meta plugin_platform_interface] - firebase_core_web 2.10.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_crashlytics_platform_interface 3.6.16 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_messaging_platform_interface 4.5.18 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_messaging_web 3.5.18 [_flutterfire_internals firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta] - fixnum 1.1.0 - flutter_cache_manager 3.3.1 [clock collection file flutter http path path_provider rxdart sqflite uuid] - flutter_facebook_auth_platform_interface 5.0.0 [flutter plugin_platform_interface] - flutter_facebook_auth_web 5.0.0 [flutter flutter_web_plugins js flutter_facebook_auth_platform_interface] - flutter_hooks 0.18.6 [flutter] - flutter_secure_storage_linux 1.2.0 [flutter flutter_secure_storage_platform_interface] - flutter_secure_storage_macos 3.0.1 [flutter flutter_secure_storage_platform_interface] - flutter_secure_storage_platform_interface 1.0.2 [flutter plugin_platform_interface] - flutter_secure_storage_web 1.1.2 [flutter flutter_secure_storage_platform_interface flutter_web_plugins js] - flutter_secure_storage_windows 3.0.0 [ffi flutter flutter_secure_storage_platform_interface path path_provider win32] - flutter_web_plugins 0.0.0 [flutter characters collection material_color_utilities meta vector_math] - frontend_server_client 3.2.0 [async path] - glob 2.1.2 [async collection file path string_scanner] - google_api_availability 3.0.1 [flutter meta] - google_identity_services_web 0.2.1+1 [js meta] - google_sign_in_android 6.1.19 [flutter google_sign_in_platform_interface] - google_sign_in_ios 5.6.3 [flutter google_sign_in_platform_interface] - google_sign_in_platform_interface 2.4.2 [flutter plugin_platform_interface quiver] - google_sign_in_web 0.12.0+5 [flutter flutter_web_plugins google_identity_services_web google_sign_in_platform_interface http js] - gql 0.14.0 [collection meta source_span] - gql_code_builder 0.7.1 [analyzer built_collection built_value code_builder collection gql gql_exec path] - gql_dedupe_link 2.0.3+1 [async gql_exec gql_link meta] - gql_error_link 0.2.3+1 [async gql_exec gql_link meta] - gql_exec 0.4.3 [collection gql meta] - gql_http_link 0.4.5 [gql gql_exec gql_link http http_parser meta] - gql_link 0.5.1 [gql gql_exec meta] - gql_transform_link 0.2.2+1 [gql_exec gql_link] - graphs 2.3.1 [collection] - hotreloader 4.2.0 [collection logging path stream_transform vm_service watcher] - http_client_helper 3.0.0 [http] - http_multi_server 3.2.1 [async] - http_parser 4.0.2 [collection source_span string_scanner typed_data] - image 4.1.3 [archive meta xml] - io 1.0.4 [meta path string_scanner] - js 0.6.7 [meta] - json_annotation 4.8.1 [meta] - leak_tracker 10.0.0 [clock collection meta path vm_service] - leak_tracker_flutter_testing 2.0.1 [flutter leak_tracker leak_tracker_testing matcher meta] - leak_tracker_testing 2.0.1 [leak_tracker matcher meta] - lints 3.0.0 - list_counter 1.0.2 - logging 1.2.0 - markdown 7.1.1 [args meta] - matcher 0.12.16+1 [async meta stack_trace term_glyph test_api] - material_color_utilities 0.8.0 [collection] - meta 1.11.0 - mime 1.0.4 - nm 0.5.0 [dbus] - normalize 0.8.2+1 [gql collection] - octo_image 2.0.0 [flutter] - os_detect 2.0.1 - package_config 2.1.0 [path] - package_info_plus_platform_interface 2.0.1 [flutter meta plugin_platform_interface] - path 1.9.0 - path_parsing 1.0.1 [vector_math meta] - path_provider_android 2.2.0 [flutter path_provider_platform_interface] - path_provider_foundation 2.3.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.1 [flutter platform plugin_platform_interface] - path_provider_windows 2.2.1 [ffi flutter path path_provider_platform_interface win32] - permission_handler_android 12.0.1 [flutter permission_handler_platform_interface] - permission_handler_apple 9.2.0 [flutter permission_handler_platform_interface] - permission_handler_html 0.1.0+1 [flutter flutter_web_plugins permission_handler_platform_interface] - permission_handler_platform_interface 4.0.2 [flutter meta plugin_platform_interface] - permission_handler_windows 0.2.0 [flutter permission_handler_platform_interface] - petitparser 5.4.0 [meta] - platform 3.1.2 - plugin_platform_interface 2.1.8 [meta] - pointycastle 3.7.3 [collection convert js] - pool 1.5.1 [async stack_trace] - pub_semver 2.1.4 [collection meta] - pubspec_parse 1.2.3 [checked_yaml collection json_annotation pub_semver yaml] - quiver 3.2.1 [matcher] - recase 4.1.0 - riverpod 2.4.9 [meta stack_trace state_notifier] - riverpod_analyzer_utils 0.3.4 [analyzer collection crypto custom_lint_core freezed_annotation meta path source_span] - rxdart 0.27.7 - share_plus_platform_interface 3.3.1 [cross_file flutter meta mime plugin_platform_interface path_provider uuid] - shared_preferences_android 2.2.1 [flutter shared_preferences_platform_interface] - shared_preferences_foundation 2.3.4 [flutter shared_preferences_platform_interface] - shared_preferences_linux 2.3.1 [file flutter path path_provider_linux path_provider_platform_interface shared_preferences_platform_interface] - shared_preferences_platform_interface 2.3.1 [flutter plugin_platform_interface] - shared_preferences_web 2.2.1 [flutter flutter_web_plugins shared_preferences_platform_interface] - shared_preferences_windows 2.3.1 [file flutter path path_provider_platform_interface path_provider_windows shared_preferences_platform_interface] - shelf 1.4.1 [async collection http_parser path stack_trace stream_channel] - shelf_web_socket 1.0.4 [shelf stream_channel web_socket_channel] - sign_in_with_apple_platform_interface 1.0.0 [flutter plugin_platform_interface meta] - sign_in_with_apple_web 1.0.1 [flutter flutter_web_plugins sign_in_with_apple_platform_interface js] - sky_engine 0.0.99 - source_gen 1.4.0 [analyzer async build dart_style glob path source_span yaml] - source_helper 1.3.4 [analyzer collection source_gen] - source_span 1.10.0 [collection path term_glyph] - sqflite 2.3.0 [flutter sqflite_common path] - sqflite_common 2.5.0 [synchronized path meta] - stack_trace 1.11.1 [path] - state_notifier 1.0.0 [meta] - stream_channel 2.1.2 [async] - stream_transform 2.1.0 - string_scanner 1.2.0 [source_span] - synchronized 3.1.0 - talker 4.0.2 [talker_logger] - talker_logger 4.0.2 [ansicolor] - term_glyph 1.2.1 - test_api 0.6.1 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph] - timing 1.0.1 [json_annotation] - typed_data 1.3.2 [collection] - universal_io 2.2.2 [collection meta typed_data] - url_launcher_android 6.2.0 [flutter url_launcher_platform_interface] - url_launcher_ios 6.2.1 [flutter url_launcher_platform_interface] - url_launcher_linux 3.1.0 [flutter url_launcher_platform_interface] - url_launcher_macos 3.1.0 [flutter url_launcher_platform_interface] - url_launcher_platform_interface 2.2.0 [flutter plugin_platform_interface] - url_launcher_web 2.2.1 [flutter flutter_web_plugins url_launcher_platform_interface web] - url_launcher_windows 3.1.0 [flutter url_launcher_platform_interface] - uuid 3.0.7 [crypto] - vector_graphics 1.1.9+1 [flutter vector_graphics_codec] - vector_graphics_codec 1.1.9+1 - vector_graphics_compiler 1.1.9+1 [args meta path_parsing xml vector_graphics_codec path] - vector_math 2.1.4 - version 3.0.2 - vm_service 13.0.0 - watcher 1.1.0 [async path] - web_socket_channel 2.4.0 [async crypto stream_channel] - webview_flutter_android 3.15.0 [flutter webview_flutter_platform_interface] - webview_flutter_platform_interface 2.10.0 [flutter meta plugin_platform_interface] - webview_flutter_wkwebview 3.12.0 [flutter path webview_flutter_platform_interface] - win32 5.0.7 [ffi] - win32_registry 1.1.1 [ffi win32] - xdg_directories 1.0.3 [meta path] - xml 6.3.0 [collection meta petitparser] - yaml 3.1.2 [collection source_span string_scanner] - youtube_player_iframe_web 3.0.1 [http flutter flutter_web_plugins web webview_flut ```

bqubique commented 8 months ago

@keithcwk does this occur on Android or iOS? On my side Android redelivers the same notification multiple times whereas on iOS, once the notification is consumed it does not get delivered again.

keithcwk commented 8 months ago

@bqubique it occurs on both Android and iOS

Lyokone commented 8 months ago

Hello @keithcwk, are you testing this in release mode instead of debug? Notification will sometime not be properly passed through when using debug mode.

keithcwk commented 8 months ago

@Lyokone As i've mentioned, this is a production issue, and we do have genuine complaints from our users. All the instances of the errors are all coming from release mode & production as well

matt-hall-zory commented 8 months ago

Same issue here. Running from release mode, force closing and booting from terminated state, it appears to be that the issue is intermittent failure of the entire system. Force closing and booting my app and about 50% of the time I can't even retrieve fcmToken. When installing and booting directly from flutter it works fine. This is only from a terminated state. It's extremely difficult to provide any debug information from Flutter from a terminated state. I have gotten it working with a workaround. I introduced a 1 second delay before calling FirebaseMessage.instance.getToken(); You've likely got a race condition in there somewhere.

asiteandroid commented 7 months ago

Any update on this? We are facing same issue

benlc commented 6 months ago

We're facing the same issue on iOS only it seems. I've been trying to reproduce this on through various scenarios, including going into airplane mode, and it seems like getInitialMessage is often empty on iOS but not on Android. We've verified codepath against firebase's doc like @keithcwk did

dishankjindal1 commented 6 months ago

For me as well, both getInitialMessage and onMessageOpenedApp is not working. but onMessage is working fine.

Poloten commented 5 months ago

Is there any solution for this problem?

MattyBoy4444 commented 5 months ago

This really needs to be looked into. This also happens to us in Release with Android. @Lyokone - Do you need additional information?

Poloten commented 4 months ago

Lyokone If I call FirebaseMessaging.instance.getInitialMessage().then((val) => .....) after few times later, (I mean some seconds), it works... In Main initState() - it doesn't work. May be u can writter better bridge, like a stream ? Or maybe Future can't be resolved until message received if exist. Now it is unstable behaviour.

Upd: I debug that case. When Push received in terminated state, the application starts and call in the Main method InitState() without any click... I think it's not normal.

NicolasGodfather commented 4 months ago

I have the same problem, Is there any solution for this?

keithcwk commented 2 months ago

Would like to humbly request for this issue to be investigated

While recently we haven't been noticing any null data being returned from getInitialMessage, we are currently facing issues where consumed initial messages are returned multiple times, similar to what is reported in the following issues

https://github.com/firebase/flutterfire/issues/12411 https://github.com/firebase/flutterfire/issues/10768

The code given in the example was able to replicate the outcome in release mode