#1 2016-08-18 11:03:45

Kasito
Banned
Registered: 2016-08-05
Posts: 58

How do check if internet is available on device

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.

Offline

#2 2016-08-18 12:41:11

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,660
Website

Re: How do check if internet is available on device

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.

Offline

#3 2016-08-20 19:04:19

Kasito
Banned
Registered: 2016-08-05
Posts: 58

Re: How do check if internet is available on device

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.

Offline

#4 2016-08-20 19:13:00

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,660
Website

Re: How do check if internet is available on device

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.

Offline

Board footer

Powered by FluxBB


Copyright ©2018 DecSoft. All rights reserved.