Hi,
How can I check if the device is connected to the internet?
Thanks.
Hi,
How can I check if the device is connected to the internet?
Thanks.
Next time, try to search first:
http://community.thunkable.com/t/internet-connection-check-solved/2091
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
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.
I tried with URL:
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.
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
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.
Another option. If it is impossible to get an answer, an error occurs. This example should work 100%.