Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

phonegap: store data until network is detected

I'm writing an App that allows a user to describe something in a few form fields then take a picture of it. The data and photo are saved on our server so it can be viewed in real time, anywhere. If there isn't a network connection can I store the data locally until the connection is detected again? Once the network connection is detected can I then post the data to the server in the background?

It seems to me that there is probably an obvious solution (plug in, threads, forums) but if there is, it's evading me.

Thanks in advance!

like image 655
Todd Gordon Avatar asked May 22 '26 02:05

Todd Gordon


1 Answers

You need to listen to the online and offline events. If you get an offline event trip a flag so you know you need to start storing your data locally. Then when you get the online event you can sync up with your server.

like image 105
Simon MacDonald Avatar answered May 25 '26 11:05

Simon MacDonald