Skip to content
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

firebase_messaging/iOS: Invalid fetch response, expected 'token' or 'Error' key #13558

Closed
1 task done
bqubique opened this issue Oct 27, 2024 · 115 comments · Fixed by #13570
Closed
1 task done

firebase_messaging/iOS: Invalid fetch response, expected 'token' or 'Error' key #13558

bqubique opened this issue Oct 27, 2024 · 115 comments · Fixed by #13570
Labels
platform: ios Issues / PRs which are specifically for iOS. plugin: messaging type: bug Something isn't working

Comments

@bqubique
Copy link

bqubique commented Oct 27, 2024

Is there an existing issue for this?

  • I have searched the existing issues.

Which plugins are affected?

Messaging

Which platforms are affected?

iOS

Description

Calling FirebaseMessaging.instance.getToken() throws this error:

FLTFirebaseMessaging: An error occurred while calling method Messaging#getToken, errorOrNil => {
    NSLocalizedFailureReason = "Invalid fetch response, expected 'token' or 'Error' key";
}

instead of getToken I used getAPNSToken() method, which returns a token, but in the background, with -FIRDebugEnabled flag enabled I can still see this error:
11.2.0 - [FirebaseMessaging][I-FCM040002] Invalid fetch response, expected 'token' or 'Error' key
right after:

11.2.0 - [FirebaseMessaging][I-FCM040000] Register request to https://fcmtoken.googleapis.com/register content: [...]

I'm using flavors with Flutter and have made sure that the correct GoogleService-Info.plist is being loaded based on the content object of the above-mentioned request.

Android has no issues with the getToken method.

Reproducing the issue

Use this flutterfire bundle-service-file script:

environment="default"
if [[ $CONFIGURATION =~ -([^-]*)$ ]]; then
environment=${BASH_REMATCH[1]}
fi

echo $environment

GOOGLESERVICE_INFO_PLIST=GoogleService-Info.plist

#### Replace the path with the correct path based on your flavors!.
GOOGLESERVICE_INFO_FILE=${PROJECT_DIR}/flavors/${environment}/${GOOGLESERVICE_INFO_PLIST}

# Get a reference to the destination location for the GoogleService-Info.plist
# This is the default location where Firebase init code expects to find GoogleServices-Info.plist file
PLIST_DESTINATION=${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app

# Copy over the prod GoogleService-Info.plist for Release builds
cp "${GOOGLESERVICE_INFO_FILE}" "${PLIST_DESTINATION}"

Firebase Core version

3.6.0

Flutter Version

3.24.3

Relevant Log Output

No response

Flutter dependencies

Expand Flutter dependencies snippet
Dart SDK 3.5.3
Flutter SDK 3.24.3
banct_mobile_app 1.2.2+94

dependencies:
- animations 2.0.11 [flutter]
- apple_product_name 3.2.0 [flutter device_info_plus]
- async 2.11.0 [collection meta]
- camera 0.10.6 [camera_android camera_avfoundation camera_platform_interface camera_web flutter flutter_plugin_android_lifecycle]
- collection 1.18.0
- crop 0.5.5 [flutter collision vector_math]
- cupertino_icons 1.0.8
- dart_dash_otp 1.3.4 [crypto base32]
- device_info_plus 10.1.2 [device_info_plus_platform_interface ffi file flutter flutter_web_plugins meta web win32 win32_registry]
- dio 5.7.0 [async http_parser meta path dio_web_adapter]
- easy_pie_chart 1.0.0 [flutter]
- encrypt 5.0.3 [args asn1lib clock collection crypto pointycastle]
- file_picker 6.2.1 [flutter flutter_web_plugins flutter_plugin_android_lifecycle plugin_platform_interface ffi path win32]
- firebase_analytics 11.3.3 [firebase_analytics_platform_interface firebase_analytics_web firebase_core firebase_core_platform_interface flutter]
- firebase_core 3.6.0 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_crashlytics 4.1.3 [firebase_core firebase_core_platform_interface firebase_crashlytics_platform_interface flutter stack_trace]
- firebase_messaging 15.1.3 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta]
- fl_chart 0.68.0 [equatable flutter]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine]
- flutter_image_compress 2.3.0 [flutter flutter_image_compress_platform_interface flutter_image_compress_common flutter_image_compress_web flutter_image_compress_macos flutter_image_compress_ohos]
- flutter_keyboard_visibility 6.0.0 [meta flutter_keyboard_visibility_platform_interface flutter_keyboard_visibility_linux flutter_keyboard_visibility_macos flutter_keyboard_visibility_web flutter_keyboard_visibility_windows flutter]
- flutter_layout_grid 2.0.7 [flutter collection quiver]
- flutter_local_notifications 17.2.2 [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]
- flutter_luban 0.1.14 [flutter image]
- flutter_native_splash 2.4.1 [args flutter flutter_web_plugins html image meta path universal_io xml yaml ansicolor]
- flutter_quill 10.5.17 [flutter flutter_localizations intl dart_quill_delta collection quiver equatable meta html flutter_colorpicker flutter_quill_delta_from_html markdown charcode url_launcher flutter_keyboard_visibility quill_native_bridge]
- flutter_quill_delta_from_html 1.4.0 [dart_quill_delta html]
- flutter_quill_extensions 10.5.17 [flutter http path meta universal_html cross_file flutter_quill photo_view youtube_explode_dart video_player youtube_player_flutter url_launcher super_clipboard gal gal_linux image_picker]
- flutter_riverpod 2.5.1 [collection flutter meta riverpod state_notifier]
- flutter_secure_storage 9.2.2 [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.10+1 [flutter http vector_graphics vector_graphics_codec vector_graphics_compiler]
- freezed_annotation 2.4.4 [collection json_annotation meta]
- fresh_dio 0.4.2 [dio fresh]
- go_router 14.2.7 [collection flutter flutter_web_plugins logging meta]
- google_fonts 6.2.1 [flutter http path_provider crypto]
- http_parser 4.0.2 [collection source_span string_scanner typed_data]
- infinite_scroll_pagination 4.0.0 [flutter flutter_staggered_grid_view sliver_tools]
- intl 0.19.0 [clock meta path]
- jiffy 6.3.1 [intl]
- json_annotation 4.9.0 [meta]
- local_auth 2.3.0 [flutter local_auth_android local_auth_darwin local_auth_platform_interface local_auth_windows]
- logger 2.4.0
- material_design_icons_flutter 7.0.7296 [flutter]
- multiselect 0.1.0 [flutter states_rebuilder]
- open_filex 4.5.0 [flutter ffi]
- path_provider 2.1.4 [flutter path_provider_android path_provider_foundation path_provider_linux path_provider_platform_interface path_provider_windows]
- permission_handler 11.3.1 [flutter meta permission_handler_android permission_handler_apple permission_handler_html permission_handler_windows permission_handler_platform_interface]
- pinput 4.0.0 [flutter smart_auth universal_platform]
- plaid_flutter 3.1.8 [flutter flutter_web_plugins plugin_platform_interface js]
- rxdart 0.28.0
- scan 1.6.0 [flutter]
- sembast 3.7.4 [meta path synchronized]
- share_plus 10.0.2 [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 web win32]
- shared_preferences 2.3.2 [flutter shared_preferences_android shared_preferences_foundation shared_preferences_linux shared_preferences_platform_interface shared_preferences_web shared_preferences_windows]
- simple_shadow 0.3.1 [flutter]
- smooth_sheets 0.8.2 [collection flutter meta]
- timer_count_down 2.2.2 [flutter]
- vibration 2.0.1 [flutter vibration_platform_interface]
- vsc_quill_delta_to_html 1.0.5 [html_unescape collection meta]

dev dependencies:
- build_runner 2.4.12 [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.6.7 [analyzer analyzer_plugin args async ci cli_util collection custom_lint_core freezed_annotation json_annotation meta package_config path pub_semver pubspec_parse rxdart uuid yaml]
- flutter_driver 0.0.0 [file flutter flutter_test fuchsia_remote_debug_protocol path meta vm_service webdriver async boolean_selector characters clock collection leak_tracker leak_tracker_flutter_testing leak_tracker_testing matcher material_color_utilities platform process source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api vector_math]
- flutter_flavorizr 2.2.3 [flutter archive args checked_yaml collection image io json_annotation sprintf xml yaml]
- flutter_lints 3.0.2 [lints]
- flutter_test 0.0.0 [flutter test_api matcher path fake_async clock stack_trace vector_math leak_tracker_flutter_testing async boolean_selector characters collection leak_tracker leak_tracker_testing material_color_utilities meta source_span stream_channel string_scanner term_glyph vm_service]
- freezed 2.5.7 [analyzer build build_config collection meta source_gen freezed_annotation json_annotation dart_style]
- icons_launcher 3.0.0 [args image path universal_io yaml]
- integration_test 0.0.0 [flutter flutter_driver flutter_test path vm_service async boolean_selector characters clock collection fake_async file leak_tracker leak_tracker_flutter_testing leak_tracker_testing matcher material_color_utilities meta source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api vector_math webdriver]
- json_serializable 6.8.0 [analyzer async build build_config collection json_annotation meta path pub_semver pubspec_parse source_gen source_helper]
- riverpod_lint 2.3.13 [analyzer analyzer_plugin collection custom_lint_builder meta path riverpod riverpod_analyzer_utils source_span yaml]

dependency overrides:
- flutter_inappwebview_ios 1.0.13 [flutter flutter_inappwebview_platform_interface]
- flutter_inappwebview_macos 1.0.11 [flutter flutter_inappwebview_platform_interface]
- flutter_inappwebview_platform_interface 1.0.11 [flutter flutter_inappwebview_internal_annotations plugin_platform_interface]
- flutter_inappwebview_web 1.0.8 [flutter flutter_web_plugins js flutter_inappwebview_platform_interface]

transitive dependencies:
- _fe_analyzer_shared 72.0.0 [meta]
- _flutterfire_internals 1.3.44 [collection firebase_core firebase_core_platform_interface flutter meta]
- _macros 0.3.2
- analyzer 6.7.0 [_fe_analyzer_shared collection convert crypto glob macros meta package_config path pub_semver source_span watcher yaml]
- analyzer_plugin 0.11.3 [analyzer collection dart_style pub_semver yaml]
- ansicolor 2.0.3
- archive 3.6.1 [crypto path]
- args 2.5.0
- asn1lib 1.5.4
- base32 2.1.3
- 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.2 [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.2 [analyzer async build collection convert crypto graphs logging package_config path pool pub_semver stream_transform yaml]
- build_runner_core 7.3.2 [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.9.2 [built_collection collection fixnum meta]
- camera_android 0.10.9+11 [camera_platform_interface flutter flutter_plugin_android_lifecycle stream_transform]
- camera_avfoundation 0.9.17+3 [camera_platform_interface flutter stream_transform]
- camera_platform_interface 2.8.0 [cross_file flutter plugin_platform_interface stream_transform]
- camera_web 0.3.5 [camera_platform_interface flutter flutter_web_plugins stream_transform web]
- characters 1.3.0
- charcode 1.3.1
- checked_yaml 2.0.3 [json_annotation source_span yaml]
- ci 0.1.0
- cli_util 0.4.1 [meta path]
- clock 1.1.1
- code_builder 4.10.0 [built_collection built_value collection matcher meta]
- collision 0.0.3 [vector_math]
- convert 3.1.1 [typed_data]
- cross_file 0.3.4+2 [meta web]
- crypto 3.0.5 [typed_data]
- csslib 1.0.0 [source_span]
- custom_lint_builder 0.6.7 [analyzer analyzer_plugin collection custom_lint custom_lint_core glob hotreloader meta package_config path pubspec_parse rxdart]
- custom_lint_core 0.6.5 [analyzer analyzer_plugin collection glob matcher meta package_config path pubspec_parse source_span yaml]
- dart_quill_delta 10.5.17 [collection diff_match_patch quiver]
- dart_style 2.3.7 [analyzer args collection package_config path pub_semver source_span]
- dbus 0.7.10 [args ffi meta xml]
- device_info_plus_platform_interface 7.0.1 [flutter meta plugin_platform_interface]
- diff_match_patch 0.4.1
- dio_web_adapter 2.0.0 [dio http_parser meta web]
- equatable 2.0.5 [collection meta]
- fake_async 1.3.1 [clock collection]
- ffi 2.1.3
- file 7.0.0 [meta path]
- file_selector_linux 0.9.2+1 [cross_file file_selector_platform_interface flutter]
- file_selector_macos 0.9.4 [cross_file file_selector_platform_interface flutter]
- file_selector_platform_interface 2.6.2 [cross_file flutter http plugin_platform_interface]
- file_selector_windows 0.9.3+2 [cross_file file_selector_platform_interface flutter]
- firebase_analytics_platform_interface 4.2.5 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_analytics_web 0.5.10+2 [_flutterfire_internals firebase_analytics_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins]
- firebase_core_platform_interface 5.3.0 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_core_web 2.18.1 [firebase_core_platform_interface flutter flutter_web_plugins meta web]
- firebase_crashlytics_platform_interface 3.6.44 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- firebase_messaging_platform_interface 4.5.46 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_messaging_web 3.9.2 [_flutterfire_internals firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins meta web]
- fixnum 1.1.0
- flutter_colorpicker 1.1.0 [flutter]
- flutter_image_compress_common 1.0.5 [flutter flutter_image_compress_platform_interface]
- flutter_image_compress_macos 1.0.2 [flutter flutter_image_compress_platform_interface]
- flutter_image_compress_ohos 0.0.3 [flutter flutter_image_compress_platform_interface]
- flutter_image_compress_platform_interface 1.0.5 [flutter plugin_platform_interface cross_file]
- flutter_image_compress_web 0.1.4+1 [flutter flutter_web_plugins flutter_image_compress_platform_interface js]
- flutter_inappwebview 6.0.0 [flutter flutter_inappwebview_platform_interface flutter_inappwebview_android flutter_inappwebview_ios flutter_inappwebview_macos flutter_inappwebview_web]
- flutter_inappwebview_android 1.1.3 [flutter flutter_inappwebview_platform_interface]
- flutter_inappwebview_internal_annotations 1.1.1
- flutter_keyboard_visibility_linux 1.0.0 [flutter_keyboard_visibility_platform_interface flutter]
- flutter_keyboard_visibility_macos 1.0.0 [flutter_keyboard_visibility_platform_interface flutter]
- flutter_keyboard_visibility_platform_interface 2.0.0 [flutter meta plugin_platform_interface]
- flutter_keyboard_visibility_web 2.0.0 [flutter_keyboard_visibility_platform_interface flutter_web_plugins flutter]
- flutter_keyboard_visibility_windows 1.0.0 [flutter_keyboard_visibility_platform_interface flutter]
- flutter_local_notifications_linux 4.0.1 [dbus ffi flutter flutter_local_notifications_platform_interface path xdg_directories]
- flutter_local_notifications_platform_interface 7.2.0 [flutter plugin_platform_interface]
- flutter_plugin_android_lifecycle 2.0.22 [flutter]
- flutter_secure_storage_linux 1.2.1 [flutter flutter_secure_storage_platform_interface]
- flutter_secure_storage_macos 3.1.2 [flutter flutter_secure_storage_platform_interface]
- flutter_secure_storage_platform_interface 1.1.2 [flutter plugin_platform_interface]
- flutter_secure_storage_web 1.2.1 [flutter flutter_secure_storage_platform_interface flutter_web_plugins js]
- flutter_secure_storage_windows 3.1.2 [ffi flutter flutter_secure_storage_platform_interface path path_provider win32]
- flutter_staggered_grid_view 0.7.0 [flutter]
- flutter_web_plugins 0.0.0 [flutter characters collection material_color_utilities meta vector_math]
- fresh 0.4.3
- frontend_server_client 4.0.0 [async path]
- fuchsia_remote_debug_protocol 0.0.0 [process vm_service file meta path platform]
- gal 2.3.0 [flutter]
- gal_linux 0.1.0 [flutter gal path]
- glob 2.1.2 [async collection file path string_scanner]
- graphs 2.3.2 [collection]
- hotreloader 4.2.0 [collection logging path stream_transform vm_service watcher]
- html 0.15.4 [csslib source_span]
- html_unescape 2.0.0
- http 1.2.2 [async http_parser meta web]
- http_multi_server 3.2.1 [async]
- image 4.2.0 [archive meta xml]
- image_picker 1.1.2 [flutter image_picker_android image_picker_for_web image_picker_ios image_picker_linux image_picker_macos image_picker_platform_interface image_picker_windows]
- image_picker_android 0.8.12+13 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface]
- image_picker_for_web 3.0.5 [flutter flutter_web_plugins image_picker_platform_interface mime web]
- image_picker_ios 0.8.12 [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.10.0 [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]
- io 1.0.4 [meta path string_scanner]
- irondash_engine_context 0.5.4 [flutter plugin_platform_interface]
- irondash_message_channel 0.7.0 [flutter ffi]
- js 0.6.7 [meta]
- leak_tracker 10.0.5 [clock collection meta path vm_service]
- leak_tracker_flutter_testing 3.0.5 [flutter leak_tracker leak_tracker_testing matcher meta]
- leak_tracker_testing 3.0.1 [leak_tracker matcher meta]
- lints 3.0.0
- local_auth_android 1.0.44 [flutter flutter_plugin_android_lifecycle intl local_auth_platform_interface]
- local_auth_darwin 1.4.0 [flutter intl local_auth_platform_interface]
- local_auth_platform_interface 1.0.10 [flutter plugin_platform_interface]
- local_auth_windows 1.0.11 [flutter local_auth_platform_interface]
- logging 1.2.0
- macros 0.1.2-main.4 [_macros]
- markdown 7.2.2 [args meta]
- matcher 0.12.16+1 [async meta stack_trace term_glyph test_api]
- material_color_utilities 0.11.1 [collection]
- meta 1.15.0
- mime 1.0.6
- navigation_builder 0.0.4 [flutter]
- package_config 2.1.0 [path]
- path 1.9.0
- path_parsing 1.0.1 [vector_math meta]
- path_provider_android 2.2.10 [flutter path_provider_platform_interface]
- path_provider_foundation 2.4.0 [flutter path_provider_platform_interface]
- path_provider_linux 2.2.1 [ffi flutter path path_provider_platform_interface xdg_directories]
- path_provider_platform_interface 2.1.2 [flutter platform plugin_platform_interface]
- path_provider_windows 2.3.0 [ffi flutter path path_provider_platform_interface]
- permission_handler_android 12.0.12 [flutter permission_handler_platform_interface]
- permission_handler_apple 9.4.5 [flutter permission_handler_platform_interface]
- permission_handler_html 0.1.3+2 [flutter flutter_web_plugins permission_handler_platform_interface web]
- permission_handler_platform_interface 4.2.3 [flutter meta plugin_platform_interface]
- permission_handler_windows 0.2.1 [flutter permission_handler_platform_interface]
- petitparser 6.0.2 [meta]
- photo_view 0.15.0 [flutter]
- pixel_snap 0.1.5 [flutter]
- platform 3.1.5
- plugin_platform_interface 2.1.8 [meta]
- pointycastle 3.9.1 [collection convert js]
- pool 1.5.1 [async stack_trace]
- process 5.0.2 [file path platform]
- pub_semver 2.1.4 [collection meta]
- pubspec_parse 1.3.0 [checked_yaml collection json_annotation pub_semver yaml]
- quill_native_bridge 10.5.17 [flutter plugin_platform_interface]
- quiver 3.2.2 [matcher]
- riverpod 2.5.1 [collection meta stack_trace state_notifier]
- riverpod_analyzer_utils 0.5.4 [analyzer collection crypto custom_lint_core freezed_annotation meta path source_span]
- share_plus_platform_interface 5.0.0 [cross_file flutter meta mime plugin_platform_interface path_provider uuid]
- shared_preferences_android 2.3.2 [flutter shared_preferences_platform_interface]
- shared_preferences_foundation 2.5.2 [flutter shared_preferences_platform_interface]
- shared_preferences_linux 2.4.1 [file flutter path path_provider_linux path_provider_platform_interface shared_preferences_platform_interface]
- shared_preferences_platform_interface 2.4.1 [flutter plugin_platform_interface]
- shared_preferences_web 2.4.2 [flutter flutter_web_plugins shared_preferences_platform_interface web]
- shared_preferences_windows 2.4.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 2.0.0 [shelf stream_channel web_socket_channel]
- sky_engine 0.0.99
- sliver_tools 0.2.12 [flutter]
- smart_auth 2.0.0 [flutter flutter_web_plugins]
- source_gen 1.5.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]
- sprintf 7.0.0
- stack_trace 1.11.1 [path]
- state_notifier 1.0.0 [meta]
- states_rebuilder 6.4.0 [flutter flutter_localizations collection meta navigation_builder]
- stream_channel 2.1.2 [async]
- stream_transform 2.1.0
- string_scanner 1.2.0 [source_span]
- super_clipboard 0.8.22 [flutter collection meta super_native_extensions]
- super_native_extensions 0.8.22 [flutter flutter_web_plugins meta ffi collection path uuid irondash_engine_context irondash_message_channel device_info_plus pixel_snap web]
- sync_http 0.3.1
- synchronized 3.2.0
- term_glyph 1.2.1
- test_api 0.7.2 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph]
- timezone 0.9.4 [path]
- timing 1.0.1 [json_annotation]
- typed_data 1.3.2 [collection]
- universal_html 2.2.4 [async csslib charcode collection html meta source_span typed_data universal_io]
- universal_io 2.2.2 [collection meta typed_data]
- universal_platform 1.1.0
- url_launcher 6.3.0 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows]
- url_launcher_android 6.3.10 [flutter url_launcher_platform_interface]
- url_launcher_ios 6.3.1 [flutter url_launcher_platform_interface]
- url_launcher_linux 3.2.0 [flutter url_launcher_platform_interface]
- url_launcher_macos 3.2.0 [flutter url_launcher_platform_interface]
- url_launcher_platform_interface 2.3.2 [flutter plugin_platform_interface]
- url_launcher_web 2.3.3 [flutter flutter_web_plugins url_launcher_platform_interface web]
- url_launcher_windows 3.1.2 [flutter url_launcher_platform_interface]
- uuid 4.5.0 [crypto sprintf meta fixnum]
- vector_graphics 1.1.11+1 [flutter http vector_graphics_codec]
- vector_graphics_codec 1.1.11+1
- vector_graphics_compiler 1.1.11+1 [args meta path_parsing xml vector_graphics_codec path]
- vector_math 2.1.4
- vibration_platform_interface 0.0.2 [flutter plugin_platform_interface device_info_plus]
- video_player 2.9.1 [flutter html video_player_android video_player_avfoundation video_player_platform_interface video_player_web]
- video_player_android 2.7.3 [flutter video_player_platform_interface]
- video_player_avfoundation 2.6.1 [flutter video_player_platform_interface]
- video_player_platform_interface 6.2.2 [flutter plugin_platform_interface]
- video_player_web 2.3.2 [flutter flutter_web_plugins video_player_platform_interface web]
- vm_service 14.2.5
- watcher 1.1.0 [async path]
- web 1.0.0
- web_socket 0.1.6 [web]
- web_socket_channel 3.0.1 [async crypto stream_channel web web_socket]
- webdriver 3.0.3 [matcher path stack_trace sync_http]
- win32 5.5.4 [ffi]
- win32_registry 1.1.5 [ffi win32]
- xdg_directories 1.0.4 [meta path]
- xml 6.5.0 [collection meta petitparser]
- yaml 3.1.2 [collection source_span string_scanner]
- youtube_explode_dart 2.2.1 [collection freezed_annotation html http http_parser json_annotation meta xml]
- youtube_player_flutter 9.0.3 [flutter flutter_inappwebview]

Additional context and comments

Xcode 16.0
Build version 16A242d
iOS 18.0

@bqubique bqubique added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Oct 27, 2024
@bqubique bqubique changed the title firebase_messaging: Invalid fetch response, expected 'token' or 'Error' key firebase_messaging/iOS: Invalid fetch response, expected 'token' or 'Error' key Oct 27, 2024
@YashOEncureIT
Copy link

I am also facing this issue. Did you find any solution, @bqubique ?

@aabughazaleh
Copy link

aabughazaleh commented Oct 28, 2024

I have the same issue using https://github.com/invertase/firestore-ios-sdk-frameworks.git version 11.2.0

I downgrade to 11.0.0, everything works fine, I'm using flutter and I can't upgrade to firebase sdk version 11.4.0 untill firebase upgrade their packages dependencies in flutter.

My problem occurs only on iOS simulator (using irestore-ios-sdk-frameworks.git version 11.2.0), but on physical devices everything works perfectly.

my firebase packages after downgrading:
firebase_core: 3.4.0
cloud_firestore: 5.4.0
firebase_auth: 5.2.0
firebase_analytics: 11.3.0
firebase_messaging: 15.1.0
firebase_crashlytics: 4.1.0
firebase_storage: 12.2.0

@bqubique
Copy link
Author

bqubique commented Oct 28, 2024

@YashOEncureIT not yet...
@aabughazaleh I haven't tried downgrading yet, but I haven't updated my dependencies lately to see this issue. Before, the issue was happening probably because I wasn't injecting the correct GoogleService-Info.plist but now that I do, I still see this issue. And getToken was working fine with both iOS simulator and real devices.

@SelaseKay SelaseKay added plugin: messaging platform: ios Issues / PRs which are specifically for iOS. labels Oct 28, 2024
@SelaseKay
Copy link
Contributor

SelaseKay commented Oct 28, 2024

Hi @bqubique , thanks for the report. This seems to be related to firebase/firebase-ios-sdk#13969. I believe once we bump the iOS sdk version, this issue should be resolved. For the time being, can you try downgrading to see if that resolves your issue for now?

@SelaseKay SelaseKay added the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Oct 28, 2024
@jakobkollerup
Copy link

jakobkollerup commented Oct 28, 2024

HI I am facing the same issues, and also tried downgrading to:
firebase_core: 3.4.0
firebase_analytics: 11.3.0
firebase_messaging: 15.1.0

Without luck

getting error code:
FLTFirebaseMessaging: An error occurred while calling method Messaging#getToken, errorOrNil => { NSLocalizedFailureReason = "Invalid fetch response, expected 'token' or 'Error' key";

lutter: [firebase_messaging/unknown] An unknown error has occurred. flutter: #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:648:7) message_codecs.dart:648 #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18) platform_channel.dart:334 <asynchronous suspension> #2 MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:534:43) platform_channel.dart:534 <asynchronous suspension> #3 MethodChannelFirebaseMessaging.getToken (package:firebase_messaging_platform_interface/src/method_channel/method_channel_messaging.dart:248:11) method_channel_messaging.dart:248 <asynchronous suspension>

@bqubique
Copy link
Author

@SelaseKay unfortunately even after pinning the versions down to:

  firebase_analytics: 11.3.0
  firebase_core: 3.4.1
  firebase_crashlytics: 4.1.0
  firebase_messaging: 15.1.0

I still get the same issue. As I said, I have not updated my packages lately for this issue to occur :(.

@raflisusanto
Copy link

Having the same issue on two of my Flutter projects. I also did not make any changes to the codebase

1st project:
firebase_core: ^2.27.1 firebase_messaging: ^14.9.4

2nd project
firebase_core: ^2.31.0 firebase_auth: ^4.19.5 firebase_messaging: ^14.9.2 firebase_crashlytics: ^3.5.5 firebase_remote_config: ^4.4.5 firebase_analytics: ^10.10.5

@TranTanPhuoc
Copy link

Hi. I have the same issue too. Have you found a solution yet? Please help me.
my firebase packages after downgrading:
firebase_messaging: ^14.7.6
firebase_core: ^2.24.0.

@bqubique
Copy link
Author

Hi. I have the same issue too. Have you found a solution yet? Please help me.
my firebase packages after downgrading:
firebase_messaging: ^14.7.6
firebase_core: ^2.24.0.

Try using APNs token for now for iOS+?

@google-oss-bot google-oss-bot removed the blocked: customer-response Waiting for customer response, e.g. more information was requested. label Oct 29, 2024
@aabughazaleh
Copy link

aabughazaleh commented Oct 29, 2024

I noticed the problem only on iOS Emulator, I tested on physical iphone using release version and I got a token without problem.

I searched chatgpt for a solution and the answer is:
This issue is known to be more common on emulators than physical devices, so testing on a physical device could yield different results.

@bqubique
Copy link
Author

I noticed the problem only iOS Emulator, I tested on physical iphone using release version and I got a token without problem.

I searched chatgpt for a solution and the answer is:
This issue is known to be more common on emulators than physical devices, so testing on a physical device could yield different results.

Until now, since February of this year, I have never had this issue. Tested on a range of iOS devices, simulators, my own physical iOS device I have never seen it happen. ChatGPT response is pretty generic tbh. As @SelaseKay said, they need to bump the iOS SDK version to alleviate this issue.

@TranTanPhuoc
Copy link

Hi. I have the same issue too. Have you found a solution yet? Please help me.
my firebase packages after downgrading:
firebase_messaging: ^14.7.6
firebase_core: ^2.24.0.

Try using APNs token for now for iOS+?

I using APNs token. I using it about 11 month and not update or upgrade but it crashed again yesterday but in the meantime I didn't do anything or change anything.

@AnwerShehata
Copy link

I have the same problem

An error occurred while calling method Messaging#getToken, errorOrNil => {
NSLocalizedFailureReason = "Invalid fetch response, expected 'token' or 'Error' key";
}
[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: [firebase_messaging/unknown] An unknown error has occurred.
#0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:651:7)
#1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)

#2 MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:534:43)

#3 MethodChannelFirebaseMessaging.getToken

@Dohmanlechx
Copy link

I noticed the problem only iOS Emulator, I tested on physical iphone using release version and I got a token without problem.

I searched chatgpt for a solution and the answer is: This issue is known to be more common on emulators than physical devices, so testing on a physical device could yield different results.

Relieved to hear that, but still it should not be happening.

@andrea-abelio
Copy link

I have the same issue, I didn't change anything since the last time it worked !

firebase_core: ^2.14.0
firebase_messaging: ^14.6.4

@kyosima
Copy link

kyosima commented Oct 29, 2024

same here

@joliph-invoked
Copy link

I got the same issue, It's working in Real device but failed in Simulator.

@Rejvenn
Copy link

Rejvenn commented Oct 29, 2024

It all worked fine yesterday, not it doesn't. I didn't change anything in the project since yesterday. can anyone please help with this ?

@MinhToan-Bastek
Copy link

Yesterday I was still able to use it, but all day today I had the same problem as above. help me :((
firebase_messaging: ^14.7.10
firebase_core: ^2.24.2
firebase_analytics: ^10.8.0

@letien91
Copy link

I had the same issue, only in iOS. I fixed it by removing the APNs from Firebase and re-adding it.

@joliph-invoked
Copy link

@letien91 Have you removed APNs Auth Key or APNs Certificates ?

@harshitGit-01
Copy link

@letien91 If you could please specify in detail what you removed and re-added

@letien91
Copy link

@letien91 Have you removed APNs Auth Key or APNs Certificates ?

Yes, I removed the APNs and created new ones. Then, I replaced the old APNs in the Firebase console with the new ones.

@zamvar
Copy link

zamvar commented Nov 5, 2024

firebase_messaging:
    git:
      url: https://github.com/firebase/flutterfire.git
      ref: messaging-13558
      path: packages/firebase_messaging/firebase_messaging

Works for me, but, is it worth the fix to production, or wait a few days for the official release?

Not working for me. And yes i remove Pods folder and Podfile.lock

[firebase_messaging/apns-token-not-set] APNS token has not been set yet. Please ensure the APNS token is available by calling `getAPNSToken()`.

@ziqq didnt work for me at first until i clear my pub cache, and make sure that pub get gets the correct package

@viniciusweber
Copy link

@DanielBidx- na próxima semana no próximo ciclo de lançamento 👍

Olá, obrigado pela correção. :)

Alguma chance de fazer backport para ser lançado com a versão anterior do pacote também? Digamos, como 14.9.5 .

Se concordar, estou disponível para abrir um PR para essa finalidade.

imagem Imagem para referência, fornecer a correção na v14.XX ajudaria quem ainda não pode atualizar para a v15 devido a alterações mínimas no SDK ou outros motivos de alterações drásticas

I believe many need it.

@ZoftPranav
Copy link

what is the fix for this ?, can someone help?

@HasanAlqaisi
Copy link

what is the fix for this ?, can someone help?

change your pubspec.yaml to this:

  firebase_messaging:
    git:
      url: https://github.com/firebase/flutterfire.git
      ref: messaging-13558
      path: packages/firebase_messaging/firebase_messaging

Then:

  1. remove pods folder & Podfile.lock from ios folder
  2. flutter clean && flutter pub get
  3. cd ios && pod install && pod repo update
  4. run the app

@restucciaquito
Copy link

what is the fix for this ?, can someone help?

change your pubspec.yaml to this:

  firebase_messaging:
    git:
      url: https://github.com/firebase/flutterfire.git
      ref: messaging-13558
      path: packages/firebase_messaging/firebase_messaging

Then:

  1. remove pods folder & Podfile.lock from ios folder
  2. flutter clean && flutter pub get
  3. cd ios && pod install && pod repo update
  4. run the app

This solution works. But I understand that it has to be a kind of “patch” until a new version of the package is released, correct? What would be the final solution? Or can I leave the pubspec.yaml like this?

@HasanAlqaisi
Copy link

what is the fix for this ?, can someone help?

change your pubspec.yaml to this:

  firebase_messaging:
    git:
      url: https://github.com/firebase/flutterfire.git
      ref: messaging-13558
      path: packages/firebase_messaging/firebase_messaging

Then:

  1. remove pods folder & Podfile.lock from ios folder
  2. flutter clean && flutter pub get
  3. cd ios && pod install && pod repo update
  4. run the app

This solution works. But I understand that it has to be a kind of “patch” until a new version of the package is released, correct? What would be the final solution? Or can I leave the pubspec.yaml like this?

You're right! We need to wait for a new release. This PR fixes the issue.
Hopefully it will be merged soon.

@restucciaquito
Copy link

what is the fix for this ?, can someone help?

change your pubspec.yaml to this:

  firebase_messaging:
    git:
      url: https://github.com/firebase/flutterfire.git
      ref: messaging-13558
      path: packages/firebase_messaging/firebase_messaging

Then:

  1. remove pods folder & Podfile.lock from ios folder
  2. flutter clean && flutter pub get
  3. cd ios && pod install && pod repo update
  4. run the app

This solution works. But I understand that it has to be a kind of “patch” until a new version of the package is released, correct? What would be the final solution? Or can I leave the pubspec.yaml like this?

You're right! We need to wait for a new release. This PR fixes the issue. Hopefully it will be merged soon.

Thank you very much for your quick response. I need to make a change in one of the apps, can I use this patch to make a new public release of my app, or do I necessarily have to wait for the new version of the package?

@HasanAlqaisi
Copy link

what is the fix for this ?, can someone help?

change your pubspec.yaml to this:

  firebase_messaging:
    git:
      url: https://github.com/firebase/flutterfire.git
      ref: messaging-13558
      path: packages/firebase_messaging/firebase_messaging

Then:

  1. remove pods folder & Podfile.lock from ios folder
  2. flutter clean && flutter pub get
  3. cd ios && pod install && pod repo update
  4. run the app

This solution works. But I understand that it has to be a kind of “patch” until a new version of the package is released, correct? What would be the final solution? Or can I leave the pubspec.yaml like this?

You're right! We need to wait for a new release. This PR fixes the issue. Hopefully it will be merged soon.

Thank you very much for your quick response. I need to make a change in one of the apps, can I use this patch to make a new public release of my app, or do I necessarily have to wait for the new version of the package?

You're welcome.
I don't know the timeline for the next release. Depending on your needs, you could proceed with your app release now, or wait for the upcoming update if timing allows.

@GunXzy
Copy link

GunXzy commented Nov 7, 2024

what is the fix for this ?, can someone help?

change your pubspec.yaml to this:

  firebase_messaging:
    git:
      url: https://github.com/firebase/flutterfire.git
      ref: messaging-13558
      path: packages/firebase_messaging/firebase_messaging

Then:

  1. remove pods folder & Podfile.lock from ios folder
  2. flutter clean && flutter pub get
  3. cd ios && pod install && pod repo update
  4. run the app

Not working on iOS Simulator (iPhone 16 Pro Max), but it works on Android.
I want to use getToken for push notifications.

Here’s what I tried:
rm -rf ios/Pods ios/Podfile.lock
flutter clean
flutter pub get
cd ios
pod install
pod repo update

dependencies:
firebase_core: ^3.6.0
firebase_messaging:
    git:
      url: https://github.com/firebase/flutterfire.git
      ref: messaging-13558
      path: packages/firebase_messaging/firebase_messaging
static Future<String?> getDeviceToken() async {
  try {
    
    _deviceToken = await _firebaseMessaging.getToken();
    print('Device Token: $_deviceToken');
    return _deviceToken;
  } catch (e) {
    print("Error retrieving device token: $e");
    return null;
  }
}

Show message :
flutter: Error retrieving device token:
[firebase_messaging/apns-token-not-set] APNS token has not been set yet. Please ensure the APNS token is available by calling getAPNSToken().

@ziqq
Copy link

ziqq commented Nov 11, 2024

Not working.

UPD: Solved.

@FirelordJohnny
Copy link

FirelordJohnny commented Nov 12, 2024

Error getting token. iOS has been fixed, but the issue happens on android...

I/flutter ( 4824): Error getting token: [firebase_messaging/unknown] java.io.IOException: java.util.concurrent.ExecutionException: java.io.IOException: SERVICE_NOT_AVAILABLE
I/flutter ( 4824): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:648:7)
I/flutter ( 4824): #1 MethodChannel._invokeMethod (package:flutter/src/services/platform_channel.dart:334:18)
I/flutter ( 4824):
I/flutter ( 4824): #2 MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:534:43)
I/flutter ( 4824):
I/flutter ( 4824): #3 MethodChannelFirebaseMessaging.getToken (package:firebase_messaging_platform_interface/src/method_channel/method_channel_messaging.dart:248:11)
I/flutter ( 4824):
I/flutter ( 4824): #4 FirebaseService.initNotifications (package:dealwing/core/notification/firebase_service.dart:49:9)
I/flutter ( 4824):
I/flutter ( 4824): #5 main (package:dealwing/main.dart:30:3)
I/flutter ( 4824):
I/flutter ( 4824): message-Token:null

@mathbalduino
Copy link

This is still happening

@cadufreeela
Copy link

Still happening here
firebase_messaging: 15.1.3
its not working in either IOS simulator or real device (app crash)

@maulikchak
Copy link

Yes , it works for me
I made a changing getTokens() to getAPNSToken().
(Note: this is for simulator use only, to receive notifications in production mode or real device, getToken() should be used.)

@zamvar
Copy link

zamvar commented Dec 2, 2024

Yes , it works for me I made a changing getTokens() to getAPNSToken(). (Note: this is for simulator use only, to receive notifications in production mode or real device, getToken() should be used.)

please read the thread this is not the correct way to resolve the issue, and check the changelog for the package version 15.1.4

@zamvar
Copy link

zamvar commented Dec 2, 2024

Still happening here firebase_messaging: 15.1.3 its not working in either IOS simulator or real device (app crash)

please check the changelog for 15.1.4

@cadufreeela
Copy link

cadufreeela commented Dec 2, 2024 via email

@maulikchak
Copy link

i use firebase_messaging 15.1.3 and it's worked

@zamvar
Copy link

zamvar commented Dec 2, 2024

i use firebase_messaging 15.1.3 and it's worked

but dont use getAPNSToken, i already explained it here before

@yassine-bennkhay
Copy link

yassine-bennkhay commented Dec 2, 2024

I am using firebase_messaging: 15.1.4 I started getting this error again!

flutter: [firebase_messaging/apns-token-not-set] APNS token has not been set yet. Please ensure the APNS token is available by calling getAPNSToken().

Anyone getting this one?

@zamvar
Copy link

zamvar commented Dec 2, 2024

I am using firebase_messaging: 15.1.4 I started getting this error again!

flutter: [firebase_messaging/apns-token-not-set] APNS token has not been set yet. Please ensure the APNS token is available by calling getAPNSToken().

Anyone getting this one?

That is a different error and it means you haven't uploaded your APNS Key in your firebase project,

@yassine-bennkhay
Copy link

No, we use APNs authentication key and it is already in Firebase.

@yassine-bennkhay
Copy link

It's working with getAPNSToken() and not getToken(), but that's not something I want to do.

@aabughazaleh
Copy link

aabughazaleh commented Dec 3, 2024

I am using firebase_messaging: 15.1.4 I started getting this error again!

flutter: [firebase_messaging/apns-token-not-set] APNS token has not been set yet. Please ensure the APNS token is available by calling getAPNSToken().

Anyone getting this one?

@yassine-bennkhay
I got the same error, I waited for an hour, after that I tried again and I got a token, I don't know what the problem is.
If you open a new simulator you will get the same error, wait for an hour and try again.

may be it take time to register the simulator device, may be...

on real device everything works fine.

@Eldar2021
Copy link

I used:

  • firebase_core: ^3.8.0
  • firebase_messaging: ^15.1.5

But getAPNSToken() return me null always. I tested IOS similator (17.5)

  Future<String?> getFcmToken() async {
    try {
      String? fcmToken;
      if (Platform.isIOS) {
        final apnsToken = await fcm.getAPNSToken();
        if (apnsToken != null) {
          fcmToken = await fcm.getToken();
        } else {
          await Future.delayed(Duration(seconds: 3));
          final apnsToken = await fcm.getAPNSToken();
          if (apnsToken != null) fcmToken = await fcm.getToken();
        }
      } else {
        fcmToken = await fcm.getToken();
      }

      return fcmToken;
    } catch (e, s) {
      log('error: $e\n stract: $s');
      throw Exception('error: $e\n stract: $s');
    }
  }

@lflorent
Copy link

lflorent commented Dec 5, 2024

I've got the same issue, getToken() always return null but only in iOS 15.5 simulator.

This generates the following error message: APNS token has not been set yet. Please ensure the APNS token is available by calling 'getAPNSToken()'.

Here's what I tried without success:

  • Wait several secondes before ask for getToken().
  • Erase all content and settings of my 15.5 iOS simulators.
  • Wait several secondes and call getAPNSToken() before getToken()..
  • Also tried the aabughazaleh workaround but waiting 2 hours before retrying didn't help.

I used:

  • firebase_core 3.8.1
  • firebase_messaging 1.5.6.

Works well (got the token) on iOS Simulator 16.x, 17.x, 18.x.

It seems that many people still have this issue despite the fix.

@firebase firebase locked and limited conversation to collaborators Dec 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
platform: ios Issues / PRs which are specifically for iOS. plugin: messaging type: bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.