This is an old revision of the document!


Check the Network Connection in PhoneGap

Here's a little bit of Javascript code that will check the network connection in PhoneGap to make sure that the internet is available for public requests. In order to be in the app store your app must work in both online and offline modes. This simple code will satisfy those requirements.

// check to see if the network is reachable
setTimeout(function() {
  navigator.network.isReachable("www.google.com",
  networkConnectionCheck, {isIpAddress:false});
}, 500);

function networkConnectionCheck(reachability) {
  if ( reachability.remoteHostStatus == NetworkStatus.NOT_REACHABLE ) {
    navigator.notification.alert("You appear to be offline.", "your app name");
  }
};

For $9.95 Get Answers to Your PhoneGap Questions

Send me an email and explain the problem. I'll send back my step by step instructions.

Subscribe

Only $9.95

After, I'll be on retainer to answer your other questions. If you don't need any more help, cancel anytime.

Please hurry, only 2 slots are available.

comments powered by Disqus
check_the_network_connection_in_phonegap.1438612898.txt.gz · Last modified: 2020/06/01 22:53 (external edit)