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
Highlighted
New Developer
Posts: 36
Registered: ‎12-12-2013
My Device: Blackberry Z10
My Carrier: Vodafone
Accepted Solution

How to check data network connectivity on device

Hi,

 

   please suggest me how i can test whether device is having internet conectivity or not.

 

  we tried some of the Samples but no use:

  Example 1:

   if (!blackberry.system.hasDataCoverage()) {
       alert("You are not in coverage, we will attempt to send later");
   } else {
   }

 

 in config.xml

   <feature id="blackberry.system" />
   <feature id="blackberry.connection" />

 

  Example 2:

  We have tried with html5 script but it always returns true.

  if (window.navigator.onLine == false){
  }

 

 

Contributor
Posts: 38
Registered: ‎05-22-2012
My Device: Blackberry Z10

Re: How to check data network connectivity on device

Normally if the phone has internet there will either be your home wifi symbol of the Blackberry symbol in the top right corner or the screen.

New Developer
Posts: 36
Registered: ‎12-12-2013
My Device: Blackberry Z10
My Carrier: Vodafone

Re: How to check data network connectivity on device

 

Oh is it? Smiley Surprised

 

 How my code will understand about the symbol on the BB screen  top right corner. ?

Contributor
Posts: 38
Registered: ‎05-22-2012
My Device: Blackberry Z10

Re: How to check data network connectivity on device

If you are looking for some sort of diagnostics via code for whether you are connected I'm afraid I can't help you with that. The symbols are the way way most people use to check their signal.

Retired
Posts: 1,561
Registered: ‎04-12-2010
My Device: BlackBerry Z10
My Carrier: Bell

Re: How to check data network connectivity on device

For BlackBerry 10, you can use the deviceinfo extension to get detailed information on network status:
https://github.com/blackberry/WebWorks-Community-APIs/tree/master/BB10-Cordova/deviceInfo

For BBOS, I can't find an extension to give as detailed information, but hasDataCoverage should work.
https://developer.blackberry.com/bbos/html5/apis/blackberry.system.html#.hasDataCoverage

Note that hasDataCoverage is not a function, it is a boolean property. Your current usage:
blackberry.system.hasDataCoverage()

Should be:
blackberry.system.hasDataCoverage

Can you please try with that?

Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.
New Developer
Posts: 36
Registered: ‎12-12-2013
My Device: Blackberry Z10
My Carrier: Vodafone

Re: How to check data network connectivity on device

Hi Oros,

 

I got one solution last time and it is working great.

  

if (blackberry.connection.type != "none") {
     //do whtever u want to do
} else {
     standardDialog('Please check your Internet');
}

 

and in config.xml

<feature id="community.deviceInfo" />
<feature id="blackberry.connection" />

 

<rimSmiley Tongueermissions>
    <rimSmiley Tongueermit>connection</rimSmiley Tongueermit>
</rimSmiley Tongueermissions>

 

Note: blackberry.connection.type may be 'Wifi', 'Ehternet', etc

           if there is no data then it will retrurn 'none'