User online/offline status in chat app

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

You can use the
when keyboard visibility changed event
Screenshot_20200915-101604~2
and send status to db and then show accordingly.

1 Like

Great Option​:ok_hand:

1 Like

But it only shows the keyboard is visible or not … I want to detect the changing length of text in textbox. When someone continue typing then show typing else dont show typing… How can I do that??

Can you try Text box text On Text Changed block.

I tried it but when I start typing it shows typing but when I stop it still shows typing …can anyone solve

Call Clock1 enable to true. (Use one Clock Component and set time 5 seconds)

When clock1.timer
Clock1 enabled to false
Typing show enable to false.