I've read Offline Capabilities on Firebase Docs and it wasn't helpful enough.
The thing that I want to do is if user goes offline I want to set status offline. The problem is if user lost connection, user won't be able to update the status.
I've read Offline Capabilities on Firebase Docs and it wasn't helpful enough.
The thing that I want to do is if user goes offline I want to set status offline. The problem is if user lost connection, user won't be able to update the status.
Read carefully the section of that page called Presence Management. It describes how to use an onDisconnect handler to change a location of the database when the app loses its connection.
For example, to set the location "disconnectmessage" to the value "I disconnected!" when the connection is lost:
DatabaseRef presenceRef = FirebaseDatabase.getInstance().getReference("disconnectmessage"); presenceRef.onDisconnect().setValue("I disconnected!");