Reputation: 2819
I am creating an app with PhoneGap that lets a user fill out a form. If PhoneGap detects that the phone has an internet connection, it will submit the data via https to a site. If there is no internet connection, it will store the form data locally then submit it to the site once it detects that there is an internet connection again.
Here is the tricky part:
Is there some way for a PhoneGap app to check if internet is available and that any saved forms should be submitted WITHOUT the user opening the app again? Essentially, it would have to happen as a background process. Running 2-3 times a day is fine. Any ideas?
Note: This app will only be utilized on Androids and iPhones.
Upvotes: 0
Views: 3136
Reputation: 6541
You can check internet connection by the code below:
var networkState = navigator.connection.type;
if (networkState == Connection.NONE)
{
alert('No network connection!');
}
Background process can implement using some plugin, check here.
Upvotes: 1