Managing user presence with Firestore in Android

Handle your users’ online and offline status using Firestore, Firebase, and Cloud Functions in Android

The Setup

Firestore Users Collection Schema
Firestore Database

Marking a user as online

Marking user as online on Firestore and Firebase RTDB

Marking user as offline

The onDisconnect() method

onDisconnect() method example

Cloud Functions

The Solution (Thanks to Abinav Seelan 🤓)

Firebase Cloud Function for User Presence Demo
Setting up the onDisconnect Hook

Demo

Updating Firebase Database (Left) with two two devices of users Zeeshan(Left) and Wajahat(Right).

🔥 Google Dev Expert (GDE) in Android . 📱 Android Dev . 💻FOSS Contributor . 📝Writer . 🎤 Speaker . 👶 Developer Dad — 🌐Subscribe at https://wajahatkarim.com