Connection check

Hi,
How can I check if the device is connected to the internet?

Thanks.

1 Like

Next time, try to search first:

with classic thunkable I can do it … but my question was how to do with thuncable x … ???

The idea is the same…take a look on the link above

in fact, I did it but it does not work …

Hi,

Hi, try searching for a simple and high-speed online echo service. google.it is far from the best option.

One option is to request http://ip-api.com/json and check the answer.

1 Like

I tried with URL:

http://ip-api.com/json

but it gives me error:

Network request failed

while nothing Response and Status … ???

but the internet is there …

you could give me an example, thank you.

The timer in the loop set for 2 seconds.

The problem is that with frequent polling of servers your IP can be blocked, so instead of https://ipecho.net/ it’s better to use the current time service (for example https://timezonedb.com/), which can be accessed once a second and lock will not be.

%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5

I tried it works …
but if I disable the internet with the active app, it always tells me internet ok … ???

With https://timezonedb.com needs to work through the API to get time, and not just call this site.

First try my example https://ipecho.net/. It has no buttons.

ok …
I tried your solution and I confirm that it works only at the start of the app, if you connect or disconnect the internet, with the app running, always recognizes the status that recognized at startup …

Have you enabled for Timer.Loops = true? This application works well for me both at the beginning of the launch and after that.

ok, I activated loop timer …
we are almost there…

if I start the app with internet to off, show disconnect and if I put the internet on, show connect … then ok …

but if I put internet to off, always show connect … why?

I’ll redo the algorithm

Check it.

%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5

https://x.thunkable.com/projects/5bc44f9e445e8711fe3ca1d7/project/properties/designer/

does the same thing …

What version of iOS are you using? I work well on iOS 10.3 and 11.4. On Android, this example also works.

There is a more reliable way to determine the presence of a network. With https://timezonedb.com you need to take every second time and compare the current time value with the previous one. If the current time is greater than the previous one, then there is a connection, otherwise there is no connection. I will try to implement this method, but you need to register on this service to get the API key.

No, using time I don’t like the option. You need to see why my example is not working. Everything is simple in it. We regularly send a request. If the answer came - there is a connection, if there is no answer, then there is no connection.

1 Like

Another option. If it is impossible to get an answer, an error occurs. This example should work 100%.

%D0%B8%D0%B7%D0%BE%D0%B1%D1%80%D0%B0%D0%B6%D0%B5%D0%BD%D0%B8%D0%B5