User online/offline status in chat app

1 - to keep track if user online , u can use Time method

How ?

1- add timer to app with interval 5000 ms
2 - for every user data , add field “last seen timestamp”
3 - in timer … use “system time” block ( u find it with clock ) to save the timestamp in user data field every 5 seconds
4 now … to check if user is online on chat , read the “last seen timestamp” value … and use IF Condition with system time as :

if “system time block” - “last seen timestamp” > 5000 then THE USER OFFLINE , Else : the user Online


2 - to send message in notification :

1 - use the onesignal block " get subscription id" and save it for every user
2 - use this extension [Free] Extension OneSignalSend | Send onesignal notification from app itself

3 - when user send any message , send with it a notification with id to the other one with message content … if he offline the message will appear in notification even if your app is close .

1 Like