Reputation: 100
I am trying to have friends page, where I could see who is online and who is offline. Updating document to set user online is no problem. I have a useEffect that checks if currentUser exists and it would update isOnline to true. But is there a way to set isOnline to false, when user leaves Website. If user where to click signOut then its fine I could first update isOnline to false then signOut, but if user just exits how do I know he is offline? sorry if my question is confusing.
Upvotes: 0
Views: 86
Reputation: 83058
You are actually looking for a system to detect "presence". As explained in the Firebase documentation, you can use the Realtime Database to add presence to your Cloud Firestore based app.
This Firebase Blog article from 2013 is also interesting to read, to get more details on the Realtime Database presence system.
Upvotes: 1