3

I am using firebase presence to detect if someone is online or not and when someone goes offline I do some cleanup via a firebase function that triggers when they go offline.

Currently, if someone goes from wifi to cellular it triggers firebase presence onDisconnect to be called so they go offline which triggers the cleanup which in this case I do not want since they are just switching from wifi to cellular.

Any way I can cleanly handle this?

Jonovono
  • 1,979
  • 7
  • 30
  • 53

1 Answers1

3

When a user moves from one network to another, one connection drops and an another connection is opened. So the onDisconnect will fire for that first connection.

To handle this well in your code, you typically want to track multiple connections per user (as the presence sample in the documentation does) and potentially put a delay before the cleanup.

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807