0
votes

I want to control background sync of google-firebase's firestore db with persistance mode (PersistenceEnabled to true).

I'm afraid the old version client, works offline and don't know the app's version-up (with some destructive updates), may upload local-data to server when change to online. In this case, I want to check current app versions and allow/not allow before sync.

Is there any solution?

1

1 Answers

0
votes

Data in the cache is only updated when you attach a listener/observer to it. There is no automatic synchronization happening for the data in the offline cache.

This means that you can add a version check to your application startup code, before you attach any observers. Simply store a database-version field in a global document, and check against that upon application startup. If the version is greater than what the app was made to handle, show an upgrade prompt.