Handling Keepsynced() While on Background on Android and with Fcm

will KeepSynced on firebase database reference contribute to concurrent user limitation

Calling keepSynced(true) on a node keeps an empty listener on that node. As long as you have any active listeners and/or periodically write data to the database, the client will keep a connection to the backend open and thus count as one of your (limited) simultaneous connections.

Will Firebase Realtime Database Sync when the device comes online, But the Application is not opened?

When you call keepSynced(true), the Firebase Realtime Database client synchronizes the data at that location while your app is active.

If you force-kill the app, the client will not be active anymore and it won't synchronize anymore.

It may continue to synchronize for a while when your back goes into the background. Whether it does this and for how long depends on the Android version and device manufacturer. Given their efforts to reduce background data usage (to improve battery life), I'd recommend not relying on this.

Firebase onDataChange not called when device screen is locked

In doze mode the OS reduces power usage of both its own components and apps on the system. The Firebase database client relies on having an open socket connection to the server to monitor for changes. It seems likely that this socket is closed by the OS in doze mode.

The typical solution is to use Firebase Cloud Messaging to signal database changes in such a case. The FCM connection is less aggressively throttled by the OS, so messages there have a better change of making it through during doze mode.



Related Topics



Leave a reply



Submit