i'm working on chat application telegram. user should see his/her friend availability (online/offline). searched lot , found out server must send ping devices , devices reply back. think prevents app use server , device resources optimally. suppose there million of users, lots of pings in every interval, lots of device battery , bandwidth use , on.
i studied firebase , gcm. check device availability send messages them, can't use show users.
i'm interested in technology telegram used users availability.
please let me find optimal way. thanks
if @ the blog post @andre linked to, you'll see "official" firebase approach problem store value in firebase's realtime database indicates status of user. so, logic this:
- use property in database keep track of user's status (e.g. /users/{uid}/status)
- when user logs in set status "online"
- when user logs off/puts app background/is idle change value of 'status' property (e.g. "offline" (use .ondisconnect() method shown in blog post).
now, whenever fetch value of status it'll reflect user's online/offline status without relying on user being online @ time.
if want show user status of friends loop through list of friends' uid's , relevant status each. info/code seems in blog post.
Comments
Post a Comment