0

I use Firebase Realtime Database for my application. I have enabled the offline features that allow to save the queries on the device when there is a connection problem to send them when it is restored. I wanted to know when the completion block is called in this case. Is it called directly if the error is not a network error? If not, is it called once the connection is re-established and the request is sent? I would like to know more about the process

Thank you for your attention!

1 Answers1

0

Completion handlers for write operations are called once the write is committed to the server. So while you are offline they won't be called, and then if your network is restored and the writes are committed, any still registered completion handlers are invoked.

Completion handlers themselves are not persisted to the offline, disk cache though. So if the app is restarted, any pending writes will be retried, but the completion handlers will not be reregistered, and thus will not be called in that case.

If knowing the completion across restarts is important to your use-case, see:

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