Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cloud Firestore Equivalent to Realtime Database ".info/connected" ref?

I have started migrating over from Firebase Realtime Database to Cloud Firestore. I need a way for the app to be alerted to when Firestore's connection state changes, online to offline and vice versa. For clarity, I do not need this written into the Database for other instances of the App to see. This is purely for providing an Indicator to the User that their connection has dropped. In Realtime database I could achieve this by attaching a value listener to the ".info/connected" reference. But It doesn't seem that I can do this in Firestore.

Alternatively, if there is "Pending Updates" value I could listen to in the Firestore Module, that responds to there being data held Offline pending Database sync that would also work.

like image 643
Charlie Hall Avatar asked Sep 10 '26 22:09

Charlie Hall


1 Answers

There is no equivalent to Firebase Realtime Database's .info/connected in Cloud Firestore. It's in fact one of the use-cases that is explicitly called on in the blog post comparing Realtime Database and Firestore:

The Realtime Database has native support for presence -- that is, being able to tell when a user has come online or gone offline. While we do have a solution for Cloud Firestore, it's not quite as elegant.

The Firestore documentation describes a possible implementation of a presence system by combining Realtime Database and Firestore.

like image 90
Frank van Puffelen Avatar answered Sep 13 '26 15:09

Frank van Puffelen



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!