Learn to Code by Making Art
Learn programming while your create computer art by copying code from my free guide.
https://splashofcode.com

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
check_the_network_connection_in_phonegap [2013/04/25 13:25]
Joel Dare
check_the_network_connection_in_phonegap [2015/08/03 14:41]
Joel Dare
Line 1: Line 1:
 +====== 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.
 +
 +<​code>​
 +// 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"​);​
 +  }
 +};
 +</​code>​
 +
 +<​html>​
 +<​style>​
 +.csv_subscription {
 +    font-family:​ Helvetica, Arial, sans-serif;
 +    font-size: 14px;
 +    background-color:​ #E2E2E2;
 +    width: 250px;
 +    padding: 20px;
 +    margin: auto;
 +}
 +.csv_subscription a {
 +    text-decoration:​ none;
 +    display: inline-block;​
 +    font-weight:​ normal;
 +    background-color:​ #5BA0D0;
 +    color: white !important;
 +}
 +.csv_subscription p {
 +    margin: 0 0 20px 0;
 +}
 +.csv_subscription .headline {
 +    font-weight:​ bold;
 +    font-size: 1.25em;
 +    text-align: center;
 +}
 +.csv_subscription .call_container {
 +    text-align: center;
 +}
 +.csv_subscription .call_to_act {
 +    margin-bottom:​ 5px;
 +    padding: 10px;
 +    background-color:​ #​.csv_subscription {
 +    font-family:​ Helvetica, Arial, sans-serif;
 +    background-color:​ #FFBC66;
 +    width: 400px;
 +    padding: 20px;
 +    margin: auto;
 +}
 +.csv_subscription a {
 +    text-decoration:​ none;
 +    display: inline-block;​
 +    font-weight:​ normal;
 +}
 +.csv_subscription p {
 +    margin: 0 0 20px 0;
 +}
 +.csv_subscription .headline {
 +    font-weight:​ bold;
 +    font-size: 1.25em;
 +    text-align: center;
 +}
 +.csv_subscription .call_container {
 +    text-align: center;
 +}
 +.csv_subscription .call_to_act {
 +    margin-bottom:​ 5px;
 +    padding: 10px;
 +    background-color:​ #5BA0D0;
 +    color: white;
 +    font-weight:​ bold;
 +}
 +.csv_subscription .call_label {
 +    font-size: 0.75em;
 +}
 +.csv_subscription .hurry {
 +    text-align: center;
 +    font-size: 0.75em;
 +    margin-bottom:​ 0px;
 +}
 +    color: white !important;
 +    font-weight:​ bold;
 +}
 +.csv_subscription .call_label {
 +    font-size: 0.75em;
 +}
 +.csv_subscription .hurry {
 +    text-align: center;
 +    font-size: 0.75em;
 +    margin-bottom:​ 0px;
 +}
 +</​style>​
 +<div class="​csv_subscription">​
 +    <p class="​headline">​For $9.95 Get Answers to Your PhoneGap Questions</​p>​
 +    <​p>​Send me an email and explain the problem. I'll send back my step by step instructions.</​p>​
 +    <div class="​call_container">​
 +        <a class="​call_to_act"​ href="​https://​www.paypal.com/​cgi-bin/​webscr?​cmd=_s-xclick&​hosted_button_id=9EM5E2CNEFYJG">​Subscribe</​a>​
 +        <p class="​call_label">​Only $9.95</​p>​
 +    </​div>​
 +    <​p>​After,​ I'll be on retainer to answer your other questions. If you don't need any more help, cancel anytime.</​p>​
 +    <p class="​hurry">​Please hurry, only 2 slots are available.</​p>​
 +</​div>​
 +</​html>​
Learn to Code by Making Art
Learn programming while your create computer art by copying code from my free guide.
https://splashofcode.com
comments powered by Disqus
check_the_network_connection_in_phonegap.txt · Last modified: 2015/08/03 14:41 by Joel Dare