I'm trying to build a presence system using firebase. The problem is that onDisconnect is not triggering when I close my app or turn off my network connectivity.
My Code:
FirebaseDatabase firebase=FirebaseDatabase.getInstance();
firebase.getReference("Users/"+shared.getString("username","")+"/presence").onDisconnect().setValue("offline");