Skip to content

Instantly share code, notes, and snippets.

@shazron
Created July 29, 2009 23:49
Show Gist options
  • Save shazron/158461 to your computer and use it in GitHub Desktop.
Save shazron/158461 to your computer and use it in GitHub Desktop.
// PhoneGap Reachability Support
function testReachable() {
// no http:// prefix!
navigator.network.isReachable("www.google.com", testReachable_callback);
// OR by ipAddress
navigator.network.isReachable("212.32.454.32", testReachable_callback, { isIpAddress: true});
}
// NetworkStatus: 0 for NotReachable, 1 for ReachableViaCarrierDataNetwork,
// 2 for ReachableViaLocalWifiDataNetwork
function testReachable_callback(reachability)
{
alert("hostName: " + reachability.hostName + " " +
"ipAddress: " + reachability.ipAddress + " " +
"remoteHostStatus: " + reachability. remoteHostStatus + " " +
"internetConnectionStatus: " + reachability. internetConnectionStatus + " " +
"localWiFiConnectionStatus: " + reachability. localWiFiConnectionStatus
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment