1

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.

2
  • Well, I tried listening to the "offline" event but apparently this did not work for me as well as it does not quit the program. stackoverflow.com/questions/10481939/…
    – Arthur
    Mar 21, 2013 at 0:56
  • note that you can only set the event-listener after the deviceready event fired function onDeviceReady() { document.addEventListener("offline", onOffline, false); }
    – El Hocko
    Mar 21, 2013 at 1:21

1 Answer 1

1

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.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.