Detecting an internet connection?

338 views
Skip to first unread message

eric

unread,
Sep 13, 2009, 10:14:59 PM9/13/09
to phonegap
Hi,

Is there any way to detect if the device is connected to the internet
using phonegap?

thisk

unread,
Sep 14, 2009, 2:44:03 AM9/14/09
to phonegap
Hi!

http://phonegap.pbworks.com/iPhone%3A-Reachability-API-use?SearchFor=reachability&sp=1

Do you also need to detect connection speed?

Regards,
thisk

Shazron Abdullah

unread,
Sep 14, 2009, 9:52:12 AM9/14/09
to eric, phonegap
Please read the wiki at phonegap.pbworks.com, search for Reachability
on the front page.

radu

unread,
Sep 21, 2009, 4:54:52 AM9/21/09
to phonegap
I've tried that code on version 0.7.3 but the callback function is
never executed.

PanMan

unread,
Sep 21, 2009, 9:24:03 AM9/21/09
to phonegap
I have used navigator.online (only tested on iphone) to see if a
device is online. That works.
Good luck,
PanMan.

radu

unread,
Sep 21, 2009, 10:06:47 AM9/21/09
to phonegap
Thanks, it's working. Do you know by any chance how to detect if the
user has Location Services enabled?

Shazron Abdullah

unread,
Sep 21, 2009, 1:57:06 PM9/21/09
to radu, phonegap
Only on Edge.
Note that Reachability is more reliable - navigator.online can return
true if you have network access, but not necessarily Internet access.

Shazron Abdullah

unread,
Sep 21, 2009, 2:11:50 PM9/21/09
to radu, phonegap

thisk

unread,
Sep 22, 2009, 4:54:50 AM9/22/09
to phonegap
Is there a way to easily tell if ReachableViaCarrierDataNetwork is
GPRS or faster?

Right now I'm opening an image and based on the open time, I check
some predefined values for connection speed but that is not too
elegant or reliable.

On szept. 21, 20:11, Shazron Abdullah <shazron.abdul...@nitobi.com>
wrote:
> Just added this ticket:http://phonegap.lighthouseapp.com/projects/20116-iphone/tickets/18-in...
>
> On 2009-09-21, at 7:06 AM, radu wrote:
>
>
>
>
>
> > Thanks, it's working. Do you know by any chance how to detect if the
> > user has Location Services enabled?- Idézett szöveg elrejtése -
>
> - Idézett szöveg megjelenítése -

thisk

unread,
Sep 22, 2009, 9:35:59 AM9/22/09
to phonegap
Okay, I've found out why this does not work. First of all, we have 2
the isReachable defined twice in phonegap.js. I merged them and added
a check no to pass the options as undefined.

Finally, I removed GetFunctionName() from the passed callback since it
always returned "alert" as function name. So now when I pass the
callback, it is not the function, it is the function name as string.

/**
*
* @param {Function} successCallback
* @param {Function} errorCallback
* @param {Object} options (isIpAddress:boolean)
*/
Network.prototype.isReachable = function(hostName, successCallback,
options) {
options = ((options == undefined) ? {} : options);
CabLifterTV.exec("Network.isReachable", hostName, successCallback,
options);
> > - Idézett szöveg megjelenítése -- Idézett szöveg elrejtése -

thisk

unread,
Sep 23, 2009, 2:19:14 AM9/23/09
to phonegap
OMG, I can't write :)
Reply all
Reply to author
Forward
0 new messages