Offline Write Support & Sync in Plugin.Firebase.Firestore #510
Replies: 2 comments 1 reply
-
|
Hi @AdamEssenmacher , @TobiasBuchholz , This is an interesting one we could eventually describe in the doc of Firestore implementation, what do you think? |
Beta Was this translation helpful? Give feedback.
-
|
By the way @herczegzoltan , have you encountered this FirebaseException while running in offline mode?
This should be fine if a document has never been locally cached (e.g. fresh app install) and we assume it's a simple cache miss. However, as per firebase/firebase-android-sdk#173, this exception can be raised for multiple reasons, among which "Document is in an unknown state", which could be a problem that we'd want to handle. Unfortunately from what I can see while catching the FirebaseException, there is no InnerException and no accessible error code on the exception instance to positively classify this as benign cache miss. @TobiasBuchholz or @AdamEssenmacher , do you know if this is the expected behaviour of the plugin? If yes, shouldn't we surface a stable error code (e.g. FirestoreError.NotFoundFromCache) or attach the InnerException so consumers can discriminate safe cache miss vs genuine failure? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone 👋
I'm currently using Plugin.Firebase.Firestore in a .NET MAUI project, and I have a question regarding offline support for write operations.
Is there a recommended way to ensure that if I save data using SetDataAsync while the device is offline, and then close and reopen the app, the data will still sync once the device is back online?
I was considering storing the writes locally in a JSON file or using something like LiteDB to queue changes. Then, on app startup or when the network reconnects, I could push those changes to Firestore.
Does anyone have a better approach or best practices for this use case?
The goal is to allow the app to be used completely offline — even across restarts — and then automatically sync all changes to Firestore when an internet connection is available.
Thanks in advance! 🙏
Beta Was this translation helpful? Give feedback.
All reactions