Skip to content

Instantly share code, notes, and snippets.

@wajahatkarim3
Last active January 22, 2018 15:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wajahatkarim3/c47161263461418f73131911ef9cd4d0 to your computer and use it in GitHub Desktop.
Save wajahatkarim3/c47161263461418f73131911ef9cd4d0 to your computer and use it in GitHub Desktop.
Making user online of Firestore and Firebase
fun makeUserOnline(user: UserModel)
{
// Firestore
var query = FirebaseFirestore.getInstance().collection("users").document(user.userId ?: "")
user.apply {
online = true
last_active = 0
}
query.set(user)
// Firebase Status
var fbquery = FirebaseDatabase.getInstance().getReference("status/" + user.userId).setValue("online")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment