Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase presence onDisconnect triggers when going from wifi to cellular

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?

like image 874
Jonovono Avatar asked Nov 24 '25 18:11

Jonovono


1 Answers

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.

like image 61
Frank van Puffelen Avatar answered Nov 26 '25 07:11

Frank van Puffelen