Handling keepSynced() while on background on Android and with FCM

后端 未结 1 1588
长发绾君心
长发绾君心 2020-12-01 22:14

I\'m considering the use of keepSynced() for some data from Firebase Realtime Database. I understand that it will automatically sync those paths. But how does t

相关标签:
1条回答
  • 2020-12-01 22:47

    firebaser here

    Great question!

    When there is no active activity, the operating system may close the connection to the Firebase database at any time. Our SDKs don't try to prevent that, but will reconnect when the app becomes active again.

    What you're describing in your second paragraph is what we call "push to sync", where you send a push notification (typically a silent FCM data message) to trigger synchronizing of the data.

    We did something like that in last year's I/O app and, while it was a bit more complex than we wanted it to be, it worked great. We explicitly managed the connection in that case, calling goOnline() and goOffline() (after 5 minutes iirc). The main sync code can be found in the IOSched github repo.

    0 讨论(0)
提交回复
热议问题