0

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.

Burak
  • 3
  • 1
  • where are you doing it? You can find out with the user lost connection and then run code in there.... https://stackoverflow.com/a/21226812/8200290 – letsCode Aug 24 '17 at 20:49

1 Answers1

2

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!");
Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441