Run Application in 2nd Plane Cordova

0

I'm developing an application in Cordova that sends the data (registration and image) to external server, is already working, but I would like to make sure that if the user does not have internet at the time of registration, the application is running in the background waiting for an internet connection to send the data, how do I do this?

    
asked by anonymous 04.05.2015 / 20:36

2 answers

1

To do this is relatively simple since your application works as expected and you just want to add a novelty / function.

The first thing to consider is to create a service to run in the background, there are several plugins to facilitate this process. You can check the following:

link

link

With a service in the background you should expect (or listen to) the online event of Cordova. It will be issued as soon as the device connects to the Internet. More information on how to do this at this link Cordova Online Event .

When the user registers and has no internet connection you must store the information or even the request itself in the device. As soon as the online event is triggered you verify which information is saved to be registered and tries to register. However it is worth informing that if any data is not correct you will have to treat them differently, perhaps with some notification.

To save the data to the device you can use various technologies, see this response to get a better view.

    
06.05.2015 / 13:59
0

Use the plugin to check the status of the connection and place the run on a list of tasks to do. When the connection returns, an event will be triggered there and you execute that list of pending connection tasks.

You can set up a timer to check the connection from time to time. When it returns, you execute the task and cancel the timer.

Check out an example of using the here plugin.

    
04.05.2015 / 20:38