🐛 [firebase_messaging] iOS FirebaseMessagingAutoInitEnabled = NO should prevent auto initialization and calls to https://fcmtoken.googleapis.com/register
Bug report
Describe the bug
Steps to reproduce
- Setup an empty Flutter project with Firebase messaging (without any calls to the lib in the code)
- Start the app and analyze app traffic (We used proxyman on a real device) -> POST https://fcmtoken.googleapis.com/register will be called on appstart
- Set FirebaseMessagingAutoInitEnabled = NO in your Info.plist file (according to this guide)
- Uninstall the app and analyze the traffic again
- https://fcmtoken.googleapis.com/register will still be called on appstart
Expected behavior
The token registration is delayed until Messaging.messaging().autoInitEnabled = true is called
Additional context
The requests aren't called if firebase_messaging is removed from pubspec.yaml
Info.plist:

Use Case: We have to prevent data collection until users accepts the policies. Auto initialization and HTTP requests should be disabled until a user opt in. We followed this doc to achieve this.
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.7.11, on macOS 13.3.1 22E261 darwin-x64, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
[✓] Xcode - develop for iOS and macOS (Xcode 14.3)
[✗] Chrome - develop for the web (Cannot find Chrome executable at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Android Studio (version 2022.1)
[✓] Connected device (2 available)
[✓] HTTP Host Availability
Flutter dependencies
Run flutter pub deps -- --style=compact and paste the output below:
Click To Expand
Dart SDK 2.19.6
Flutter SDK 3.7.11
sample 1.0.0+1
dependencies:
- firebase_messaging 14.4.0 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta]
- flutter 0.0.0 [characters collection js material_color_utilities meta vector_math sky_engine]
dev dependencies:
- flutter_test 0.0.0 [flutter test_api path fake_async clock stack_trace vector_math async boolean_selector characters collection js matcher material_color_utilities meta source_span stream_channel string_scanner term_glyph]
- integration_test 0.0.0 [flutter flutter_driver flutter_test path vm_service archive async boolean_selector characters clock collection crypto fake_async file js matcher material_color_utilities meta source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api typed_data vector_math webdriver]
transitive dependencies:
- _flutterfire_internals 1.1.0 [collection firebase_core firebase_core_platform_interface flutter meta]
- archive 3.3.2 [crypto path]
- async 2.10.0 [collection meta]
- boolean_selector 2.1.1 [source_span string_scanner]
- characters 1.2.1
- clock 1.1.1
- collection 1.17.0
- crypto 3.0.2 [typed_data]
- fake_async 1.3.1 [clock collection]
- file 6.1.4 [meta path]
- firebase_core 2.9.0 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_core_platform_interface 4.6.0 [collection flutter flutter_test meta plugin_platform_interface]
- firebase_core_web 2.3.0 [firebase_core_platform_interface flutter flutter_web_plugins js meta]
- firebase_messaging_platform_interface 4.3.0 [_flutterfire_internals firebase_core flutter meta plugin_platform_interface]
- firebase_messaging_web 3.3.0 [_flutterfire_internals firebase_core firebase_core_web firebase_messaging_platform_interface flutter flutter_web_plugins js meta]
- flutter_driver 0.0.0 [file flutter flutter_test fuchsia_remote_debug_protocol path meta vm_service webdriver archive async boolean_selector characters clock collection crypto js matcher material_color_utilities platform process source_span stack_trace stream_channel string_scanner sync_http term_glyph test_api typed_data vector_math]
- flutter_web_plugins 0.0.0 [flutter js characters collection material_color_utilities meta vector_math]
- fuchsia_remote_debug_protocol 0.0.0 [process vm_service file meta path platform]
- js 0.6.5 [meta]
- matcher 0.12.13 [meta stack_trace]
- material_color_utilities 0.2.0
- meta 1.8.0
- path 1.8.2
- platform 3.1.0
- plugin_platform_interface 2.1.4 [meta]
- process 4.2.4 [file path platform]
- sky_engine 0.0.99
- source_span 1.9.1 [collection path term_glyph]
- stack_trace 1.11.0 [path]
- stream_channel 2.1.1 [async]
- string_scanner 1.2.0 [source_span]
- sync_http 0.3.1
- term_glyph 1.2.1
- test_api 0.4.16 [async boolean_selector collection meta source_span stack_trace stream_channel string_scanner term_glyph matcher]
- typed_data 1.3.1 [collection]
- vector_math 2.1.4
- vm_service 9.4.0
- webdriver 3.0.1 [archive matcher path stack_trace sync_http]
3. (according to this guide)
This is coming from native iOS SDK.
I couldn't find any reference or documentation from client side on auto initialization, so will keep this issue open for team's feedback.
/cc @Lyokone
@darshankawar The Flutter documentation states the same thing https://firebase.google.com/docs/cloud-messaging/flutter/client#prevent-auto-init
@adscooli You mention but should use await FirebaseMessaging.instance.setAutoInitEnabled(true); in your Dart code when you want to activate auto init.
If using the issue persists when using the correct Dart code, I'll open an issue in the native iOS SDK repository.
I also found this piece of information: https://github.com/firebase/quickstart-unity/issues/657#issuecomment-1030002415; I'll try to see if FlutterFire doesn't make a call to the native SDK by mistake.
Thanks for the quick responses.
@Lyokone
We removed await FirebaseMessaging.instance.setAutoInitEnabled(true); just to investigate this issue.
In general the push messages work fine. We just need help with the opt in.
refering to the other issue We don't have any code related to firebase currently in the project. It's basically an empty flutter project with the firebase_messaging dependency. (and the required GoogleService-Info.plist file). So the call musst be automatically triggered by a dependency.
In the meantime we did the same with Analytics link and Crashlytics link in the main project, which worked as expected and removed the related requests on appstart.
Also there are not much log outputs on appstart in the sample, still FirebaseMessaging tries to initialize something
Click To Expand Logs
2023-04-19 10:20:34.621638+0200 test DEBUG[1833:427027] Metal API Validation Enabled
2023-04-19 10:20:34.872528+0200 test DEBUG[1833:427027] Warning: Unable to create restoration in progress marker file
2023-04-19 10:20:34.876618+0200 test DEBUG[1833:427393] 10.7.0 - [FirebaseCore][I-COR000005] No app has been configured yet.
2023-04-19 10:20:35.049411+0200 test DEBUG[1833:427393] 10.7.0 - [FirebaseMessaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. If you'd prefer to manually integrate Firebase Messaging, add "FirebaseAppDelegateProxyEnabled" to your Info.plist, and set it to NO. Follow the instructions at:
https://firebase.google.com/docs/cloud-messaging/ios/client#method_swizzling_in_firebase_messaging
to ensure proper integration.
2023-04-19 10:20:35.132165+0200 test DEBUG[1833:427438] flutter: The Dart VM service is listening on http://127.0.0.1:53656/GvNTlDoS0gY=/
2023-04-19 10:20:35.787664+0200 test DEBUG[1833:427410] fopen failed for data file: errno = 2 (No such file or directory)
2023-04-19 10:20:35.787718+0200 test DEBUG[1833:427410] Errors found! Invalidating cache...
2023-04-19 10:20:35.825989+0200 test DEBUG[1833:427410] fopen failed for data file: errno = 2 (No such file or directory)
2023-04-19 10:20:35.826037+0200 test DEBUG[1833:427410] Errors found! Invalidating cache...
I have the same issue, did you find a solution?