Closed kotaroyamazaki closed 6 months ago
Reproducible using the plugin example app.
On android, the message is resolved but on iOS it was not resolved.
Labeling for further investigation.
cc @russellwheatley
i am facing this issue as well even using delay on getinitialmessage not solve the problem at all
same issue, everything works on IOS except the getInitialMessage call which always returns null for me, on android getInitialMessage works without issues.
firebase_core: ^2.12.0 firebase_messaging: ^14.6.1
Running into same problem. getInitialMessage
is always null on iOS. Interestingly, onMessageOpenedApp
is also always null when app is opened via fcm notification from background(not terminated) state. I'm able to handle background notifications via FirebaseMessaging.onBackgroundMessage
but there's no fix or workaround for FirebaseMessaging.instance.getInitialMessage
.
I'm running on latest dependencies as of this comment.
I've tried sending push notifications both via the script from examples folder and via postman. I'm able to replicate the behaviour on both the cases.
Hi Is there any solution for this?
.@russellwheatley @danagbemava-nc Please let us know when this issue will be resolved. No buddy is assign on this issue?
I just tested this in the example app, it works. getInitialMessage()
will only resolve to a RemoteMessage from a terminated state.
To test locally:
print()
in here: https://github.com/firebase/flutterfire/blob/master/packages/firebase_messaging/firebase_messaging/example/lib/main.dart#L184getInitialMessage()
resolves to a RemoteMessage
.@russellwheatley thanks a lot! I will check the example app, do you think that the sequence of calls to Firebase could cause the issues? The weird thing, for me everything works on Android and I can see data in the getInitialMessage
, but it does not work for IOS, I have put getInitialMessage
call after the FirebaseMessaging.onMessageOpenedApp.listen
and after FirebaseMessaging.onMessage.listen
, anyways thanks a lot I will try putting the call before and let you know if this solves the problem for me
Hi @russellwheatley can you please confirm details like iOS version, package version and flutter version? Because I'm still able to reproduce this using the proposed changes in https://github.com/firebase/flutterfire/pull/12371 and I'm running on the latest version of firebase_messaging.
Bug report
The getInitialMessage() method does not seem reliable, at least on iOS which I'm using for testing this.
I am encountering an issue where the getInitialMessage() is returning null exclusively on the iOS platform. This is causing a problem with handling messages from termination states on iOS devices.
Upon debugging, I found that getInitialMessage is returning null when called on an iOS device. Interestingly, the same function works as expected and processes messages correctly on Android devices.
Any insights or fixes for this iOS-specific behavior would be greatly appreciated.
Steps to reproduce
Steps to reproduce the behavior:
Expected behavior
An iOS device receives a push notification while the app is in the terminated state, and the user taps on this notification to launch the app, getInitialMessage should not return null. Instead, it should correctly retrieve and process the message.
Sample project
Additional context
library version
Processing in the background state also works fine on iOS
Flutter doctor
Run
flutter doctor
and paste the output below:Click To Expand
``` flutter doctor Doctor summary (to see all details, run flutter doctor -v): [β] Flutter (Channel stable, 3.16.7, on macOS 13.4 22F66 darwin-arm64, locale ja-US) [β] Android toolchain - develop for Android devices (Android SDK version 33.0.2) [β] Xcode - develop for iOS and macOS (Xcode 14.3) [β] Chrome - develop for the web [β] Android Studio (version 2022.2) [β] VS Code (version 1.84.2) [β] Connected device (3 available) [β] Network resources β’ No issues found! ```Flutter dependencies
Run
flutter pub deps -- --style=compact
and paste the output below:Click To Expand
``` $ flutter pub deps -- --style=compact Dart SDK 3.2.4 Flutter SDK 3.16.7 mussic 1.3.2+48 dependencies: - appsflyer_sdk 6.12.2 [flutter] - audio_session 0.1.18 [flutter flutter_web_plugins rxdart meta] - cached_network_image 3.3.0 [cached_network_image_platform_interface cached_network_image_web flutter flutter_cache_manager octo_image] - carousel_slider 4.2.1 [flutter] - collection 1.18.0 - cupertino_icons 1.0.6 - custom_nested_scroll_view 0.0.4 [flutter flutter_lints] - dart_emoji 0.2.0+2 [characters] - device_info_plus 9.1.1 [device_info_plus_platform_interface ffi file flutter flutter_web_plugins meta win32 win32_registry] - devicelocale 0.6.0 [flutter flutter_web_plugins] - dio 5.4.0 [async http_parser meta path] - dynamic_height_grid_view 0.0.4 [flutter] - equatable 2.0.5 [collection meta] - feature_flags 0.1.4 [collection shared_preferences flutter] - firebase_analytics 10.5.1 [firebase_analytics_platform_interface firebase_analytics_web firebase_core firebase_core_platform_interface flutter] - firebase_auth 4.10.1 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta] - firebase_core 2.17.0 [firebase_core_platform_interface firebase_core_web flutter meta] - firebase_crashlytics 3.3.7 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace] - firebase_dynamic_links 5.3.7 [firebase_core firebase_core_platform_interface firebase_dynamic_links_platform_interface flutter meta plugin_platform_interface] - firebase_messaging 14.6.9 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta] - firebase_performance 0.9.2+7 [firebase_core firebase_core_platform_interface firebase_performance_platform_interface firebase_performance_web flutter] - flutter 0.0.0 [characters collection material_color_utilities meta vector_math web sky_engine] - flutter_animate 4.3.0 [flutter] - flutter_app_badger 1.5.0 [flutter] - flutter_inappwebview 5.8.0 [flutter] - flutter_launcher_icons 0.13.1 [args checked_yaml cli_util image json_annotation path yaml] - flutter_local_notifications 14.1.4 [clock flutter flutter_local_notifications_linux flutter_local_notifications_platform_interface timezone] - flutter_localizations 0.0.0 [flutter intl characters clock collection material_color_utilities meta path vector_math web] - flutter_riverpod 1.0.4 [collection flutter meta riverpod state_notifier] - flutter_speed_dial 7.0.0 [flutter] - flutter_staggered_grid_view 0.7.0 [flutter] - flutter_svg 2.0.9 [flutter vector_graphics vector_graphics_codec vector_graphics_compiler] - flutter_web_plugins 0.0.0 [flutter characters collection material_color_utilities meta vector_math web] - freezed_annotation 2.4.1 [collection json_annotation meta] - google_fonts 4.0.4 [flutter http path_provider crypto] - graphql_flutter 5.1.2 [graphql gql_exec flutter meta path_provider path connectivity_plus hive plugin_platform_interface flutter_hooks] - http 0.13.6 [async http_parser meta] - humy_kit 0.0.1 [carousel_slider flutter flutter_svg cached_network_image image_picker intl lottie url_launcher video_player styled_text] - image_cropper 1.5.1 [flutter] - image_gallery_saver 2.0.3 [flutter] - image_picker 0.8.9 [flutter image_picker_android image_picker_for_web image_picker_ios image_picker_linux image_picker_macos image_picker_platform_interface image_picker_windows] - in_app_purchase 3.1.11 [flutter in_app_purchase_android in_app_purchase_platform_interface in_app_purchase_storekit] - in_app_purchase_storekit 0.3.7 [collection flutter in_app_purchase_platform_interface json_annotation] - intl 0.18.1 [clock meta path] - json_annotation 4.8.1 [meta] - mask_text_input_formatter 2.7.0 [flutter] - normalize 0.8.2+1 [gql collection] - package_info_plus 4.2.0 [ffi flutter flutter_web_plugins http meta path package_info_plus_platform_interface win32] - path 1.8.3 - permission_handler 10.4.5 [flutter meta permission_handler_android permission_handler_apple permission_handler_windows permission_handler_platform_interface] - photo_view 0.14.0 [flutter] - provider 6.1.1 [collection flutter nested] - pub_semver 2.1.4 [collection meta] - qr_flutter 4.1.0 [flutter qr] - screen_brightness 0.2.2+1 [flutter screen_brightness_platform_interface screen_brightness_android screen_brightness_ios screen_brightness_macos screen_brightness_windows] - 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] - sliver_tools 0.2.12 [flutter] - sqflite 2.3.0 [flutter sqflite_common path] - stack_trace 1.11.1 [path] - streaming_shared_preferences 2.0.0 [flutter meta shared_preferences] - styled_text 7.0.0 [flutter xmlstream] - universal_platform 1.0.0+1 - url_launcher 6.2.1 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows] - uuid 3.0.7 [crypto] - video_player 2.8.1 [flutter html video_player_android video_player_avfoundation video_player_platform_interface video_player_web] - visibility_detector 0.4.0+2 [flutter] - wakelock_plus 1.1.4 [flutter flutter_web_plugins meta wakelock_plus_platform_interface win32 dbus package_info_plus js] dev dependencies: - artemis 7.13.1 [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.7 [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] - dart_code_metrics 5.7.6 [analyzer analyzer_plugin ansicolor args collection crypto dart_code_metrics_presets file glob html http meta path platform pub_updater source_span uuid xml yaml] - firebase_core_platform_interface 4.8.0 [collection flutter flutter_test meta plugin_platform_interface] - flutter_lints 2.0.3 [lints] - flutter_test 0.0.0 [flutter test_api matcher path fake_async clock stack_trace vector_math async boolean_selector characters collection material_color_utilities meta source_span stream_channel string_scanner term_glyph web] - freezed 2.4.5 [analyzer build build_config collection meta source_gen freezed_annotation json_annotation] - json_serializable 6.7.1 [analyzer async build build_config collection json_annotation meta path pub_semver pubspec_parse source_gen source_helper] - mockito 5.4.3 [analyzer build code_builder collection dart_style matcher meta path source_gen test_api] transitive dependencies: - _fe_analyzer_shared 61.0.0 [meta] - _flutterfire_internals 1.3.7 [collection firebase_core firebase_core_platform_interface flutter meta] - analyzer 5.13.0 [_fe_analyzer_shared collection convert crypto glob meta package_config path pub_semver source_span watcher yaml] - 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.1 [built_collection built_value crypto http_multi_server logging path pool shelf shelf_web_socket stream_transform watcher web_socket_channel] - build_resolvers 2.4.1 [analyzer async build collection convert crypto graphs logging package_config path pool pub_semver stream_transform yaml] - build_runner_core 7.2.11 [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.8.0 [built_collection collection fixnum meta] - cached_network_image_platform_interface 3.0.0 [flutter flutter_cache_manager] - cached_network_image_web 1.1.0 [cached_network_image_platform_interface flutter flutter_cache_manager] - characters 1.3.0 - checked_yaml 2.0.3 [json_annotation source_span yaml] - cli_util 0.4.0 [meta path] - clock 1.1.1 - code_builder 4.8.0 [built_collection built_value collection matcher meta] - connectivity_plus 3.0.6 [flutter flutter_web_plugins connectivity_plus_platform_interface js meta nm] - connectivity_plus_platform_interface 1.2.4 [flutter meta plugin_platform_interface] - convert 3.1.1 [typed_data] - cross_file 0.3.3+8 [meta web] - crypto 3.0.3 [typed_data] - csslib 1.0.0 [source_span] - dart_code_metrics_presets 1.8.0 - dart_style 2.3.2 [analyzer args path pub_semver source_span] - dbus 0.7.10 [args ffi meta xml] - device_info_plus_platform_interface 7.0.0 [flutter meta plugin_platform_interface] - fake_async 1.3.1 [clock collection] - ffi 2.1.0 - file 6.1.4 [meta path] - file_selector_linux 0.9.2+1 [cross_file file_selector_platform_interface flutter] - file_selector_macos 0.9.3+3 [cross_file file_selector_platform_interface flutter] - file_selector_platform_interface 2.6.1 [cross_file flutter http plugin_platform_interface] - file_selector_windows 0.9.3+1 [cross_file file_selector_platform_interface flutter] - firebase_analytics_platform_interface 3.7.1 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_analytics_web 0.5.5+1 [_flutterfire_internals firebase_analytics_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins js] - firebase_auth_platform_interface 6.19.1 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_auth_web 5.8.2 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser js meta] - firebase_core_web 2.8.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta] - firebase_crashlytics_platform_interface 3.6.7 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface] - firebase_dynamic_links_platform_interface 0.2.6+7 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_messaging_platform_interface 4.5.8 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface] - firebase_messaging_web 3.5.8 [_flutterfire_internals firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta] - firebase_performance_platform_interface 0.1.4+7 [_flutterfire_internals firebase_core flutter plugin_platform_interface] - firebase_performance_web 0.1.4+7 [_flutterfire_internals firebase_core firebase_core_web firebase_performance_platform_interface flutter flutter_web_plugins js] - fixnum 1.1.0 - flutter_cache_manager 3.3.1 [clock collection file flutter http path path_provider rxdart sqflite uuid] - flutter_hooks 0.18.6 [flutter] - flutter_local_notifications_linux 4.0.0+1 [dbus ffi flutter flutter_local_notifications_platform_interface path xdg_directories] - flutter_local_notifications_platform_interface 7.0.0+1 [flutter plugin_platform_interface] - flutter_plugin_android_lifecycle 2.0.17 [flutter] - frontend_server_client 3.2.0 [async path] - glob 2.1.2 [async collection file path string_scanner] - 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] - 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] - graphs 2.3.1 [collection] - hive 2.2.3 [meta crypto] - html 0.15.4 [csslib source_span] - 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] - image_picker_android 0.8.8+2 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface] - image_picker_for_web 2.2.0 [flutter flutter_web_plugins image_picker_platform_interface mime] - image_picker_ios 0.8.8+4 [flutter image_picker_platform_interface] - image_picker_linux 0.2.1+1 [file_selector_linux file_selector_platform_interface flutter image_picker_platform_interface] - image_picker_macos 0.2.1+1 [file_selector_macos file_selector_platform_interface flutter image_picker_platform_interface] - image_picker_platform_interface 2.9.1 [cross_file flutter http plugin_platform_interface] - image_picker_windows 0.2.1+1 [file_selector_platform_interface file_selector_windows flutter image_picker_platform_interface] - in_app_purchase_android 0.3.0+15 [collection flutter in_app_purchase_platform_interface json_annotation] - in_app_purchase_platform_interface 1.3.6 [flutter plugin_platform_interface] - io 1.0.4 [meta path string_scanner] - js 0.6.7 [meta] - lints 2.1.1 - logging 1.2.0 - lottie 2.7.0 [archive flutter path vector_math] - matcher 0.12.16 [async meta stack_trace term_glyph test_api] - material_color_utilities 0.5.0 [collection] - meta 1.10.0 - mime 1.0.4 - nested 1.0.0 [flutter] - nm 0.5.0 [dbus] - octo_image 2.0.0 [flutter] - package_config 2.1.0 [path] - package_info_plus_platform_interface 2.0.1 [flutter meta plugin_platform_interface] - path_parsing 1.0.1 [vector_math meta] - path_provider 2.1.1 [flutter path_provider_android path_provider_foundation path_provider_linux path_provider_platform_interface path_provider_windows] - path_provider_android 2.2.1 [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 10.3.6 [flutter permission_handler_platform_interface] - permission_handler_apple 9.1.4 [flutter permission_handler_platform_interface] - permission_handler_platform_interface 3.12.0 [flutter meta plugin_platform_interface] - permission_handler_windows 0.1.3 [flutter permission_handler_platform_interface] - petitparser 6.0.2 [meta] - platform 3.1.3 - plugin_platform_interface 2.1.7 [meta] - pointycastle 3.7.3 [collection convert js] - pool 1.5.1 [async stack_trace] - process 4.2.4 [file path platform] - pub_updater 0.3.0 [http json_annotation process pub_semver] - pubspec_parse 1.2.3 [checked_yaml collection json_annotation pub_semver yaml] - qr 3.0.1 [meta] - recase 4.1.0 - riverpod 1.0.3 [collection meta state_notifier] - rxdart 0.27.7 - screen_brightness_android 0.1.0+2 [flutter screen_brightness_platform_interface] - screen_brightness_ios 0.1.0 [flutter screen_brightness_platform_interface] - screen_brightness_macos 0.1.0+1 [flutter screen_brightness_platform_interface] - screen_brightness_platform_interface 0.1.0 [flutter plugin_platform_interface] - screen_brightness_windows 0.1.3 [flutter screen_brightness_platform_interface] - 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.2 [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.2 [flutter flutter_web_plugins shared_preferences_platform_interface web] - shared_preferences_windows 2.3.2 [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] - 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_common 2.5.0+2 [synchronized path meta] - state_notifier 0.7.2+1 [meta] - stream_channel 2.1.2 [async] - stream_transform 2.1.0 - string_scanner 1.2.0 [source_span] - synchronized 3.1.0 - 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] - timezone 0.9.2 [path] - timing 1.0.1 [json_annotation] - typed_data 1.3.2 [collection] - 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] - 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 - video_player_android 2.4.10 [flutter video_player_platform_interface] - video_player_avfoundation 2.5.3 [flutter video_player_platform_interface] - video_player_platform_interface 6.2.1 [flutter plugin_platform_interface] - video_player_web 2.1.2 [flutter flutter_web_plugins video_player_platform_interface] - wakelock_plus_platform_interface 1.1.0 [flutter plugin_platform_interface meta] - watcher 1.1.0 [async path] - web 0.3.0 - web_socket_channel 2.4.0 [async crypto stream_channel] - win32 5.1.1 [ffi] - win32_registry 1.1.2 [ffi win32] - xdg_directories 1.0.3 [meta path] - xml 6.5.0 [collection meta petitparser] - xmlstream 1.1.1 - yaml 3.1.2 [collection source_span string_scanner] ```