3

Looking through the Firestore Documentation, I can't find anything indicating when the sync of offline data actually happens. If connectivity is restored and the application is in the background, will the sync happen then, or will it happen when the application is next launched with connectivity?

Jeff Schmitz
  • 1,087
  • 1
  • 13
  • 28

2 Answers2

0

The state of the application doesn't concern synchronization at all. The SDK just needs to have an open connection to Firestore in order to synchronize, and it will do so as soon as that connection is available, retrying as needed. The SDK will attempt to keep this connection open for as long as possible.

That said, the host OS will often shut down network access and kill app processes that are not visible to the user in the foreground. If either of those things happen, there's nothing the SDK can do.

Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441
0

Firestore's offline functions as a cache of data that the application has recently loaded, which it can access while your app is lacking a connection to the servers.

So if you get data, or keep a listener on data, that data is also stored in this offline cache. Outside of that, there is no automatic data synchronization that is being done by Firestore.

If you want certain data to be kept up to date in the offline cache, you will need to keep an active listener for updates to that data. The listener doesn't have to do anything with that data yet, but it does need to be attached for the data to be updated in the cache.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807