TobiasBuchholz / Plugin.Firebase

Wrapper around the native Android and iOS Firebase Xamarin SDKs
MIT License
220 stars 49 forks source link

Set FirestoreSettings, NetworkAccess, ClearLocalCache #93

Closed SeriousM closed 1 year ago

SeriousM commented 2 years ago
TobiasBuchholz commented 2 years ago

Is there a way to set the FirestoreSettings, in particular the CacheSizeBytes?

Yes, you can set the FirestoreSettings on the IFirebaseFirestore instance. In your case it would look like this:

var firestore = CrossFirebaseFirestore.Current;
var settings = firestore.Settings;
firestore.Settings = new FirestoreSettings(
    host: settings.Host,
    isPersistenceEnabled: settings.IsPersistenceEnabled,
    isSslEnabled: settings.IsSslEnabled,
    cacheSizeBytes: 1337L);

Is there support to control network access? Can we delete the local cache? Android, iOS

I've just created a new version 1.2.2 which implements those methods. You can find them on the IFirebaseFirestore instance.

Can you expose the local db so one could get a copy for debug insights?

As far as I know the native libraries don't offer any possibility to do something like that but please let me know if there is.

SeriousM commented 1 year ago

I wasn't aware that I'm supposed to replace the settings object as I thought it might get cached somewhere and the new instance wouldn't take effect. Maybe pointing it out in a documentation on firestore.Settings would help.

Thank you very much for extending the proxy to the native libraries in https://github.com/TobiasBuchholz/Plugin.Firebase/commit/26330773ab27e3f41bab1edf9551790bcf3b926a! That really helps!

Can you expose the local db so one could get a copy for debug insights?

As far as I know the native libraries don't offer any possibility to do something like that but please let me know if there is.

No native way so far. For anyone whos interested: You can query all root collections and documents (by iterating the known paths) by requesting only cached items and then put them into a json file.