User online/offline status in chat app

Can anyone assist me in knowing how to create blocks to know whether a user is online in a app or not ?

1 Like

Do you mean your app or another app on the user’s device?

1 Like

You can use the IsConnected block from the Network component.

1 Like

When a user login in your app you can save in a database it’s status for example online if he logins , offline if he logouts

I have created a chat messenger app. Once login it will be always logged in using device ID… So I want to show online only when user logged in and using that app… else it shud be offline. Also any idea Abt how the msg appears in notification when one user sends text to another user using my chat app

1 Like

I have created chat messenger app. In that app I want to know who all are online using my app… and any idea Abt how the msg appears in notification when one user sends text to another user using my chat app

1 Like

In order to receive notifications when someone send message to the user, the app should be run in background.

If the app is closed, no messages will receive as apps made with kodular dont support background processes.

Can you explain it with an example block?

Thank you. How about know the status of the user whether he is online or offline? can u give an example using blocks

blocks (18)

1 Like

Use network component as @Mateja said.

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

I dont know this is onesignal bug or something but when app is closed one signal notifications are not working properly that means they will not receive untill the user open the app.

I am using one signal one of my app whenever i send a push notification, it rarely delivers when the app is closed.

It will 100% deliver but not receives. Receives when user open app.

Try with blocks when initialization screen :

onesignalpush.isSubscription=True

I already did the same!

Yes, I am also experiencing the same issue. When I send the message using my chat app to another user, notification will be sent only when the app is minimized i.e. running on the background or when it is opened. It wont go when the app is closed.

This is might due to Kodular app dont run in background.

may be In future this problem will solve.

Hmm, Hope so

can u please explain me how to add last seen timestamp for each user ?

I want to show typing status. How can I do that? Please help …

Thank you