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

[cloud_firestore]: Add to app support #13685

Open
1 task done
diegogarciar opened this issue Nov 5, 2024 · 0 comments
Open
1 task done

[cloud_firestore]: Add to app support #13685

diegogarciar opened this issue Nov 5, 2024 · 0 comments
Labels
Needs Attention This issue needs maintainer attention. platform: ios Issues / PRs which are specifically for iOS. plugin: cloud_firestore type: enhancement New feature or request

Comments

@diegogarciar
Copy link
Contributor

diegogarciar commented Nov 5, 2024

Is there an existing issue for this?

  • I have searched the existing issues.

Which plugins are affected?

Database

Which platforms are affected?

iOS

Description

I'm migrating an existing iOS app into flutter using add to app. The idea of add_to_app is that you can progressively migrate or provide certain features of the app with flutter.

For my app I'm trying migrate a screen that is not loaded during app initialization, so my flutter main() code is not executed on startup. This means that I perform certain queries with the native iOS Firestore SDK before I actually use flutter.

Now, when I start my flutter screen, I initialize firebase as usual, but when I try to make a query, I have an issue because the cloud firestore plugin tries to initialize firestore as well, this causes an issue because it tries to set the firestore settings after I have already performed queries with the native SDK

if (pigeonApp.settings.cacheSizeBytes) {
NSNumber *cacheSizeBytes = pigeonApp.settings.cacheSizeBytes;
if ([cacheSizeBytes intValue] != -1) {
size = cacheSizeBytes;
}
}
if (persistEnabled) {
settings.cacheSettings = [[FIRPersistentCacheSettings alloc] initWithSizeBytes:size];
} else {
settings.cacheSettings = [[FIRMemoryCacheSettings alloc]
initWithGarbageCollectorSettings:[[FIRMemoryLRUGCSettings alloc] init]];
}
}
if (pigeonApp.settings.host != nil) {
settings.host = pigeonApp.settings.host;
// Only allow changing ssl if host is also specified.
if (pigeonApp.settings.sslEnabled != nil) {
settings.sslEnabled = [pigeonApp.settings.sslEnabled boolValue];
}
}
settings.dispatchQueue = [FLTFirebaseFirestoreReader getFirestoreQueue];
FIRFirestore *firestore = [FIRFirestore firestoreForApp:app database:databaseUrl];
firestore.settings = settings;

I know it's not a common scenario, but I would expect the firestore database to support add_to_app. I'm not sure if there could be a way to somehow bypass this or you could implement a feature/fix.

Reproducing the issue

Steps to reproduce:

  • Clone an add_to_app project from one of the examples.
  • Add cloud_firestore plugin.
  • In the iOS code, make a firestore query on the view controller before flutter is presented.
  • Add another firestore query on the flutter code
  • Run the app, verify that the native query is executed. then click on the button to show the flutter screen.

Expected result:
Flutter code should perform firestore query

Actual result:
Error is thrown, firestore settings should only be set on startup

it works fine if I remove this line

Firebase Core version

3.6.0

Flutter Version

3.24.2

Relevant Log Output

Terminating app due to uncaught exception 'FIRIllegalStateException', reason: 'Firestore instance has already been started and its settings can no longer be changed. You can only set settings before calling any other methods on a Firestore instance.

Flutter dependencies

Expand Flutter dependencies snippet
dependencies:
- another_flushbar 1.12.30 [flutter]
- app_settings 5.1.1 [flutter plugin_platform_interface]
- audio_session 0.1.21 [flutter flutter_web_plugins rxdart meta]
- cached_network_image 3.4.1 [cached_network_image_platform_interface cached_network_image_web flutter flutter_cache_manager octo_image]
- chewie 1.8.5 [cupertino_icons flutter provider video_player wakelock_plus]
- cloud_firestore 5.4.4 [cloud_firestore_platform_interface cloud_firestore_web collection firebase_core firebase_core_platform_interface flutter meta]
- cloud_functions 5.1.3 [cloud_functions_platform_interface cloud_functions_web firebase_core firebase_core_platform_interface flutter]
- collection 1.18.0
- connectivity_plus 6.1.0 [flutter flutter_web_plugins connectivity_plus_platform_interface web meta nm collection]
- dartz 0.10.1
- dio 5.7.0 [async http_parser meta path dio_web_adapter]
- equatable 2.0.5 [collection meta]
- firebase_auth 5.3.1 [firebase_auth_platform_interface firebase_auth_web firebase_core firebase_core_platform_interface flutter meta]
- firebase_core 3.6.0 [firebase_core_platform_interface firebase_core_web flutter meta]
- firebase_database 11.1.4 [firebase_core firebase_core_platform_interface firebase_database_platform_interface firebase_database_web flutter]
- firebase_messaging 15.1.3 [firebase_core firebase_core_platform_interface firebase_messaging_platform_interface firebase_messaging_web flutter meta]
- firebase_storage 12.3.4 [firebase_core firebase_core_platform_interface firebase_storage_platform_interface firebase_storage_web flutter]
- flutter 0.0.0 [characters collection material_color_utilities meta vector_math sky_engine]
- flutter_bloc 8.1.6 [bloc flutter provider]
- flutter_chat_ui 1.6.15 [diffutil_dart equatable flutter flutter_chat_types flutter_link_previewer flutter_parsed_text intl meta photo_view scroll_to_index url_launcher visibility_detector]
- flutter_localizations 0.0.0 [flutter intl characters clock collection material_color_utilities meta path vector_math]
- flutter_sound 9.16.3 [path_provider recase uuid provider path synchronized logger flutter flutter_sound_platform_interface flutter_sound_web]
- flutter_svg 2.0.11 [flutter http vector_graphics vector_graphics_codec vector_graphics_compiler]
- freezed_annotation 2.4.4 [collection json_annotation meta]
- get_it 8.0.2 [async collection meta]
- go_router 14.3.0 [collection flutter flutter_web_plugins logging meta]
- 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]
- injectable 2.5.0 [get_it meta]
- intl 0.19.0 [clock meta path]
- json_annotation 4.9.0 [meta]
- logging 1.3.0
- path_provider 2.1.5 [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]
- retry 3.1.2
- rxdart 0.28.0
- sentry_flutter 8.9.0 [flutter flutter_web_plugins sentry package_info_plus meta ffi file]
- 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]
- shimmer 3.0.0 [flutter]
- url_launcher 6.3.1 [flutter url_launcher_android url_launcher_ios url_launcher_linux url_launcher_macos url_launcher_platform_interface url_launcher_web url_launcher_windows]
- webview_flutter 4.10.0 [flutter webview_flutter_android webview_flutter_platform_interface webview_flutter_wkwebview]

dev dependencies:
- build_runner 2.4.13 [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]
- cloud_firestore_odm_generator 1.0.0-dev.89 [analyzer build build_config cloud_firestore_odm collection freezed_annotation graphs json_annotation meta recase source_gen source_helper]
- flutter_lints 5.0.0 [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]
- injectable_generator 2.6.2 [build source_gen path glob analyzer code_builder dart_style injectable collection recase meta]
- json_serializable 6.8.0 [analyzer async build build_config collection json_annotation meta path pub_semver pubspec_parse source_gen source_helper]

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]
- args 2.6.0
- async 2.11.0 [collection meta]
- bloc 8.1.4 [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.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]
- cached_network_image_platform_interface 4.1.1 [flutter flutter_cache_manager]
- cached_network_image_web 1.3.1 [cached_network_image_platform_interface flutter flutter_cache_manager web]
- characters 1.3.0
- checked_yaml 2.0.3 [json_annotation source_span yaml]
- clock 1.1.1
- cloud_firestore_odm 1.0.0-dev.88 [cloud_firestore flutter json_annotation meta]
- cloud_firestore_platform_interface 6.4.3 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- cloud_firestore_web 4.3.2 [_flutterfire_internals cloud_firestore_platform_interface collection firebase_core firebase_core_web flutter flutter_web_plugins]
- cloud_functions_platform_interface 5.5.37 [firebase_core flutter meta plugin_platform_interface]
- cloud_functions_web 4.10.2 [cloud_functions_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins]
- code_builder 4.10.1 [built_collection built_value collection matcher meta]
- connectivity_plus_platform_interface 2.0.1 [flutter meta plugin_platform_interface]
- convert 3.1.2 [typed_data]
- cross_file 0.3.4+2 [meta web]
- crypto 3.0.6 [typed_data]
- csslib 1.0.2 [source_span]
- cupertino_icons 1.0.8
- dart_style 2.3.7 [analyzer args collection package_config path pub_semver source_span]
- dbus 0.7.10 [args ffi meta xml]
- diffutil_dart 4.0.1
- dio_web_adapter 2.0.0 [dio http_parser meta web]
- fake_async 1.3.1 [clock collection]
- ffi 2.1.3
- file 7.0.1 [meta path]
- file_selector_linux 0.9.3 [cross_file file_selector_platform_interface flutter]
- file_selector_macos 0.9.4+2 [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+3 [cross_file file_selector_platform_interface flutter]
- firebase_auth_platform_interface 7.4.7 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- firebase_auth_web 5.13.2 [firebase_auth_platform_interface firebase_core firebase_core_web flutter flutter_web_plugins http_parser meta web]
- 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_database_platform_interface 0.2.5+44 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- firebase_database_web 0.2.6+2 [collection firebase_core firebase_core_web firebase_database_platform_interface flutter flutter_web_plugins]
- 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]
- firebase_storage_platform_interface 5.1.31 [_flutterfire_internals collection firebase_core flutter meta plugin_platform_interface]
- firebase_storage_web 3.10.3 [_flutterfire_internals async firebase_core firebase_core_web firebase_storage_platform_interface flutter flutter_web_plugins http meta web]
- fixnum 1.1.1
- flutter_cache_manager 3.4.1 [clock collection file flutter http path path_provider rxdart sqflite uuid]
- flutter_chat_types 3.6.2 [equatable json_annotation meta]
- flutter_link_previewer 3.2.2 [flutter flutter_chat_types flutter_linkify html http linkify meta url_launcher]
- flutter_linkify 6.0.0 [flutter linkify]
- flutter_parsed_text 2.2.1 [flutter]
- flutter_plugin_android_lifecycle 2.0.23 [flutter]
- flutter_sound_platform_interface 9.16.3 [flutter plugin_platform_interface logger]
- flutter_sound_web 9.16.3 [flutter_sound_platform_interface flutter logger flutter_web_plugins js web]
- flutter_web_plugins 0.0.0 [flutter characters collection material_color_utilities meta vector_math]
- frontend_server_client 4.0.0 [async path]
- glob 2.1.2 [async collection file path string_scanner]
- graphs 2.3.2 [collection]
- html 0.15.5 [csslib source_span]
- http 1.2.2 [async http_parser meta web]
- http_multi_server 3.2.1 [async]
- http_parser 4.0.2 [collection source_span string_scanner typed_data]
- image_picker_android 0.8.12+17 [flutter flutter_plugin_android_lifecycle image_picker_platform_interface]
- image_picker_for_web 3.0.6 [flutter flutter_web_plugins image_picker_platform_interface mime web]
- image_picker_ios 0.8.12+1 [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]
- js 0.7.1
- 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]
- linkify 5.0.0
- lints 5.0.0
- logger 2.4.0
- macros 0.1.2-main.4 [_macros]
- 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 2.0.0
- nested 1.0.0 [flutter]
- nm 0.5.0 [dbus]
- octo_image 2.1.0 [flutter]
- package_config 2.1.0 [path]
- package_info_plus 8.1.0 [ffi flutter flutter_web_plugins http meta path package_info_plus_platform_interface web win32 clock]
- package_info_plus_platform_interface 3.0.1 [flutter meta plugin_platform_interface]
- path 1.9.0
- path_parsing 1.1.0 [meta vector_math]
- path_provider_android 2.2.12 [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.13 [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]
- platform 3.1.6
- plugin_platform_interface 2.1.8 [meta]
- pool 1.5.1 [async stack_trace]
- provider 6.1.2 [collection flutter nested]
- pub_semver 2.1.4 [collection meta]
- pubspec_parse 1.3.0 [checked_yaml collection json_annotation pub_semver yaml]
- recase 4.1.0
- scroll_to_index 3.0.1 [flutter]
- sentry 8.9.0 [http meta stack_trace uuid]
- shared_preferences_android 2.3.3 [flutter shared_preferences_platform_interface]
- shared_preferences_foundation 2.5.3 [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
- 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
- sqflite 2.4.0 [flutter sqflite_android sqflite_darwin sqflite_platform_interface sqflite_common path]
- sqflite_android 2.4.0 [flutter sqflite_common path sqflite_platform_interface]
- sqflite_common 2.5.4+5 [synchronized path meta]
- sqflite_darwin 2.4.1-1 [flutter sqflite_platform_interface meta sqflite_common path]
- sqflite_platform_interface 2.4.0 [flutter platform sqflite_common plugin_platform_interface meta]
- stack_trace 1.11.1 [path]
- stream_channel 2.1.2 [async]
- stream_transform 2.1.0
- string_scanner 1.2.0 [source_span]
- synchronized 3.3.0+3
- 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]
- timing 1.0.1 [json_annotation]
- typed_data 1.4.0 [collection]
- url_launcher_android 6.3.14 [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.1 [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.3 [flutter url_launcher_platform_interface]
- uuid 4.5.1 [crypto sprintf meta fixnum]
- vector_graphics 1.1.12 [flutter http vector_graphics_codec]
- vector_graphics_codec 1.1.12
- vector_graphics_compiler 1.1.12 [args meta path path_parsing vector_graphics_codec xml]
- vector_math 2.1.4
- video_player 2.9.2 [flutter html video_player_android video_player_avfoundation video_player_platform_interface video_player_web]
- video_player_android 2.7.16 [flutter video_player_platform_interface]
- video_player_avfoundation 2.6.2 [flutter video_player_platform_interface]
- video_player_platform_interface 6.2.3 [flutter plugin_platform_interface]
- video_player_web 2.3.3 [flutter flutter_web_plugins video_player_platform_interface web]
- visibility_detector 0.4.0+2 [flutter]
- vm_service 14.2.5
- wakelock_plus 1.2.8 [flutter flutter_web_plugins meta wakelock_plus_platform_interface win32 dbus package_info_plus web]
- wakelock_plus_platform_interface 1.2.1 [flutter plugin_platform_interface meta]
- watcher 1.1.0 [async path]
- web 1.1.0
- web_socket 0.1.6 [web]
- web_socket_channel 3.0.1 [async crypto stream_channel web web_socket]
- webview_flutter_android 4.0.0 [flutter webview_flutter_platform_interface]
- webview_flutter_platform_interface 2.10.0 [flutter meta plugin_platform_interface]
- webview_flutter_wkwebview 3.16.0 [flutter path webview_flutter_platform_interface]
- win32 5.7.2 [ffi]
- xdg_directories 1.1.0 [meta path]
- xml 6.5.0 [collection meta petitparser]
- yaml 3.1.2 [collection source_span string_scanner]

Additional context and comments

Thought this is a bug, maybe it doesn't really need to be fixed, I'm open to suggestions on how to bypass this issue, maybe we call on AppDelegate

i.e

 [FLTFirebaseFirestoreUtils setCachedFIRFirestoreInstance:firestore
                                                  forAppName:app.name
                                                 databaseURL:databaseUrl];

though I'm not sure if FLTFirebaseFirestoreUtils is public

@diegogarciar diegogarciar added Needs Attention This issue needs maintainer attention. type: bug Something isn't working labels Nov 5, 2024
@SelaseKay SelaseKay added type: enhancement New feature or request plugin: cloud_firestore platform: ios Issues / PRs which are specifically for iOS. and removed type: bug Something isn't working labels Nov 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Attention This issue needs maintainer attention. platform: ios Issues / PRs which are specifically for iOS. plugin: cloud_firestore type: enhancement New feature or request
2 participants