How do check if internet is available on device


Guest

I want to confirm if internet is available on user device before load show an app page or load web based page in app page, if there is no internet available the to show a message box and stop.


decsoft

Hello Kasito,

In principle (and in theory) we can use the "[App.Online]" variable as well the app's "Online" and "Offline" events. The "GetNetworkType" action can be useful here too. This probably works like a charm in Cordova's builded apps.

Browsers are a little different here. The browsers' vendors can more or less support the refered stuff, and, in fact all of them support right now or want to support in the future, however, the browsers' vendors can implement the "Online/Offline" API in possible different ways.

Then how the hell we can know if we are online or not? Probably the best solution (in addition to the refered stuff) is to perform an HTTP call to our server... and wait for their answer. This is probably the only reliable way to know if we can access our online resources or not.



Guest

I'm learning AB with a cordova based app. Do u have an example existing in AB? I want something like, Seek for network if not found do nothing Else Goto.

It can seek for a remote resource on sever, but how do I get the answer and decide what the app should do next?

Examples will really help.

Thanks.


decsoft

Hello Kasito,

What you must to do is in principle quite simple. You can perform an HTTP call using the HttpClient control. This control offer us two events: "Success" and "Error". The first one is fired if the server response is good. The second one is fired if the server response is bad or never exists. So you can use these events in order to decide what the app must be do next.


Everybody can read the DecSoft support forum for learning purposes, however only DecSoft customers can post new threads. Purchase one or more licenses of some DecSoft products in order to give this and other benefits.

This website uses some useful cookies to store your preferences.

I agree. Hide this note. Give me more information.