Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Web and WebWorks Development

Reply
Regular Contributor
hoangan_it
Posts: 63
Registered: ‎06-08-2012
My Device: BlackBerry
My Carrier: BlackBerry

How to check Internet access form WebWorks app

Hi all,

 

Coudl you tell me the way to check Internet access from my WebWorks app?

 

Thanks so much and Best regards,

 

An Pham

Please use plain text.
Regular Contributor
liammccann
Posts: 68
Registered: ‎06-12-2012
My Device: Blackberry Bold 9780
My Carrier: Vodafone

Re: How to check Internet access form WebWorks app

By internet do you mean what kind of connection or just in general do you have internet?
Please use plain text.
Regular Contributor
liammccann
Posts: 68
Registered: ‎06-12-2012
My Device: Blackberry Bold 9780
My Carrier: Vodafone

Re: How to check Internet access form WebWorks app

Use has data coverage, https://developer.blackberry.com/html5/apis/blackberry.system.html

This will return true if you have access false if you dont.

Depending what your using (smartphone/playbook) you can use on coverage change to check when your connection type changes.

Hope this helps
Please use plain text.
Regular Contributor
hoangan_it
Posts: 63
Registered: ‎06-08-2012
My Device: BlackBerry
My Carrier: BlackBerry

Re: How to check Internet access form WebWorks app

Hi liammaccann,

I have just used this way!
Unfortunately, it is not the way to check internet access (I want to check my playbook is available access Internet or not so)

Do you have the other way?
See you soon!
Please use plain text.
Developer
biggerCC
Posts: 270
Registered: ‎12-13-2010
My Device: PlayBook 16GB, BB10 Dev Alpha
My Carrier: o2 (de)

Re: How to check Internet access form WebWorks app

Yeah, blackberry.system.hasDataCoverage will just tell you, if that PlayBook is connected to a WiFi and not if that WiFi has internet access.

 

Why don't you just try to access your desired resource and set a fast request timeout with user friendly error handling (e.g. ajax load animation and after 5 seconds a "Sorry, you need to be connected to the Internet" message)?

- - -
My approved apps @ App World
Please use plain text.
Regular Contributor
hoangan_it
Posts: 63
Registered: ‎06-08-2012
My Device: BlackBerry
My Carrier: BlackBerry

Re: How to check Internet access form WebWorks app

Hi biggerCC and liammccann,

Great! thank you very much! ^^

An Pham
Please use plain text.
Regular Contributor
liammccann
Posts: 68
Registered: ‎06-12-2012
My Device: Blackberry Bold 9780
My Carrier: Vodafone

Re: How to check Internet access form WebWorks app

Yes i agree with biggerCC, even try pulling a sample bit of data and if you get it then internet works if not fails.. like a sort of ping idea if im understing you correcltly @biggerCC ?
Please use plain text.
Developer
biggerCC
Posts: 270
Registered: ‎12-13-2010
My Device: PlayBook 16GB, BB10 Dev Alpha
My Carrier: o2 (de)

Re: How to check Internet access form WebWorks app

It depends on your app and the data to be transmitted.

 

Here's what works for me (app with local DB and a webservice that supplies weather information, marketplace items, custom map entries, ...):

Upon app startup I usually check weather the device has any kind of connection (WebWorks/PhoneGap SDK). If the device has no connection at all, I'll skip all connection efforts (for a defined timeframe).

If there is a connection, I send a small request (init) to my webservice, followed by a tiny reply (just hash tags which signalize if and which parts of my app's offline database need to be updated). This call even takes <2 secs with a 2G connection. So a timeout of this request after 5 or 10 seconds clearly states: no internet is available at the moment!

If the app already has preloaded data available for offline use, I'll display that and try the init call again a couple of minutes later. If not, I show a warning "Internet connection required.".

- - -
My approved apps @ App World
Please use plain text.