Can I store picture locally and upload in the background when wifi is available?

Hi,
I’m trying to make an app that allows the user to take a picture while offline (got that part covered), store it locally (I’m good), and then upload it to a remote server whenever the user has access to an internet connection, maybe with a toggle to only upload when connected via wifi if possible.

As far as android is concerned, it seems the app would need to declare a receiver for the CONNECTIVITY_ACTION broadcast in the manifest so that it receives the broadcast even if the app is closed, and then have a service that listens to this broadcast and starts uploading as soon as we have a connection.

The problem is I have absolutely no idea how to do any of that in Ionic2 (or plain Cordova for that matter).

Thanks for your help

edit :
OK, it seems I can use the cordova-plugin-network-information plugin to monitor changes, but that would only work while the app is active right ?
I could probably keep the app alive with the background-mode plugin, but that seems less than ideal.

1 Like

Do ServiceWorkers not work with Cordova? They’d be perfect for this.

Unfortunately no, service workers don’t work with ionic : https://github.com/driftyco/ionic/issues/9977

Any updates on the issue? Got a similar problem, but with simple notes instead of pictures…

Any updates on the issue? Got a similar problem?
please let me know