2 questions about handling no internet connection in applications?

I have an application, that is used for monitoring purposes, which shows the data from a farm that is stored in firebase. I thought it'll be good on my part to handle situations where the user can know whether the internet connection is poor/ non existent. below is the code for the same.

My thinking is: get the responseCode by visiting https://www.google.com every 30 seconds , if it is 200 (successfully reached) then just do the same continuously , but if the response is not 200, then try the same but every 10 seconds for 3 times and if the problem still persists, then show an alert to quit the application else if the internet comes back within those 3 tries, then just show an alert that the internet is back online, and reset the clock to go off every 30 seconds again.

TimerAlwaysFires and TimerEnabled sections of Internet checker clock is checked.

To test it out , i built the app and opened the app, then just switched off the mobile data after some time; now the problem is none of those alerts ever popped up ! all i got was below! Any idea why it would happen ?

Question 2: when i switch to other app (without giving quit from the app or clearing it from the recent apps section) i get the below ! that is still overlays into other apps , i tried handling this by disabling the timer when i quit the app, but since that block won't be triggered when just go between apps , i was wondering if there's a better way of achieving the objective ?!

i hope i made my use case clear, any insight into this is appreciated thanks!!

a) how often do you need to check/update the farm data ? Is this every 30 seconds ? Is this really necessary?
b) Why not try the simple internet checker extension as an alternative?

a) Have you considered using the Taifun Tools extension ActivityStateChanged event for stopping/starting your clock timer when you switch apps?
b) Have you considered using the Screen ErrorOccured block to capture the connection error and prevent it from appearing, or providing a message in the app only instead of a device wide message?

@TIMAI2 thanks for going through the long post !!

Yes, the data is updated every 30 seconds in the farm and for the rest, all of it is new to me !

I was wondering why the web component wouldn't just give a number other than 200 when the internet is turned off

i'll look into those links , can you confirm if my approach was on the right track though ?

It just seems like using a sledgehammer to crack a nut....

With the extension you can just check for internet - if it is there fetch data, if not provide message to try again in a bit, and/or automate to try again with a clock timer.

i'll try to make it that way then! :+1:

a simple example:


thanks a lot for the snippet , i'll integrate it with mine and revert back !

If you are looking for more options:

Hi Somasundharam

I don't see a Screen Error Block to capture the error? With that, you can display your own message in your own message label. All the Internet checking is entirely superfluous, as Tim has said - if the connection fails, let the User know, as per Tim's example, but maybe with a count down so the User can see something is happening. If, after say three minutes, there is still no connection, then and only then you might test for another site like Google to determine if the problem is specific to the farm.