How to detect if app (phone) is offline?

How to detect if app (phone) is offline?
I’d like to show a different screen for when the app is offline.

Thank you!

You can use the device is online? block
https://docs.thunkable.com/device#get-online-offline-status

2 Likes

I am wondering,
If get other users online / offline status :joy::joy:

1 Like

What do you mean? Like if in a chat app if the other person is onlice or not? If so that would require you to have each device send a “ping” to your firebase. I used one for a game that sent every 5 mins and then other devices checked the list and if a user hadnt pinged in the last 5 mins it was removed from the “online” list.

1 Like

Thank you for the responses! I meant just the user running the app, that component Connor mentioned solves it, apparently.

2 Likes

Oh I have interest @samclever

1 Like

What is it you’d like to know?

May I?

1 Like

All i did was had a Parent in Firebase that said ONLINE and then when a user signed online the app would send an entry to that Parent as their UserName(id) and a timestamp. Every 3 mins that user would send an updated timestamp. Then each person online would send a call every 5 mins that would call ONLINE, make a list out of each entry and then run a procedure to remove all entry’s over 5 mins. I no longer have the example but if you understand the basics of it you should be able to make it work. The only thing I didnt know was how much data was used for each user constantly making and sending calls to Firebase PLUS, you would end up having to pay Firebase as you would use up all your calls/gets fairly quickly.

1 Like

This is a cool way to check if users are engaged with the app!

1 Like

Problem

This solution unfortunately doesn’t work so well. Because your device can be “online” which means it is connected via LTE or Wifi, but it doesn’t necessarily mean you are connected to the internet. My advice is to use a Firebase tag or some sort of actual method of checking if the devices is in fact connected, by attempting to pull a piece of data from a database of some sort (Firebase being an easy choice). And once you’ve received the value, then you’ll be “online”.

Example

If your app uses Firebase and Firebase is currently down (which it is sometimes), then you can be online but not necessarily connected to the database, which subsequently would cause the app to not work, if of course your app relies on that database…

(edit)

To add, I have tested this and this is a problem I have had, especially when slow internet gets too slow to work.

2 Likes

I have 5 users, i wonder which one is online which one is offline. I can use firebase or airtable.
And also i used airtable, if device is online writing online it is good.
But how can i learn which ones are offline? I didnt write offline on Airtable for this block.
https://docs.thunkable.com/device#get-online-offline-status

If i found devices imei number or something like that it will be great. Because of i didnt write sign-signup blocks we dont need. If i find with blocks any devices specific id i will set on airtable for online but how can i write offline i have no idea too.
I tried 3 blocks but i cant.

To define online users, you need to create a timer in the application that will periodically save the current value of the variable in a separate node. Using a different timer, the value of this variable is checked. If the value in the monitored node has not changed after the control time, it means that the user is not online.

2 Likes