Arthur
Arthur

Reputation: 223

How to display a message/picture alert if there is no internet connection (PhoneGap)?

Problems (PhoneGap):

  1. How to display a message/picture alert if there is no internet connection?
  2. How to prevent user to use/fully open the application after the alert (quit the application and display alerts later until user connects to the Internet)?

Thank you in advance.

Upvotes: 1

Views: 798

Answers (1)

dsaa
dsaa

Reputation: 487

There's Phonegap documentation on this here. It discusses creating an 'alert' for various connection states.

I don't have much experience on platforms other than Android, but if you use the Phonegap database feature, data storage is persistant within a table if the app is 'force closed' or simply suspended.

To achieve what you're looking for, I would create a very simple table with a boolean value corresponding to whether there is network availability, which is updated through a function call based around timed javascript functions. A simple if(){} statement can then check the database value and either limit or enable functionality in the app.

Depending on how persistant you want the data to be, you could also do away with the database and just make a timed call to return the network status.

Upvotes: 1

Related Questions