Run Application in 2nd Cordova Plan

Asked

Viewed 2,207 times

0

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

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 be considered is to create a service to run in the background, there are several plugins to facilitate this process. You can check the following:

https://github.com/katzer/cordova-plugin-background-mode

https://github.com/Red-Folder/Cordova-Plugin-BackgroundService

With a service in the background you should wait (or listen) the event online 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 in the device. As soon as the event online If triggered you check what information is saved to be registered and try to register. However it is valid to inform that if any given is not correct you will have to treat them differently, perhaps with some notification.

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

0

Use the plugin to check the connection status and put the execution in a list of tasks to be done. When the connection comes back, an event will be triggered then you run that list of pending connection tasks.

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

Check an example of using the plugin here.

  • Okay, I get it but I need it to work in the style of "Dropbox", even if you close or minimize the application on the phone it still sends the data, has how to do this?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.