Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Running background task on startup

I'm writing an iOS app that uses the Dropbox Datastore API to sync data across multiple devices.

On Android, I'm able to tell the service to start on boot, which enables it to sync any changes that may have occurred whilst the device was turned off.

I'm having trouble finding a definitive way to have my app do the same on iOS.

So, does anyone have any recommendations to:

  • Run a simple background service efficiently and dependably on iOS.
  • Have the service start at boot

This must be possible - apps like Facebook and Gmail start syncing as soon as the device finishes booting.

like image 560
Phillip Elm Avatar asked Dec 25 '22 17:12

Phillip Elm


2 Answers

Run a simple background service efficiently and dependably on iOS.

You cannot run background services on iOS. You can perform some operations in background, but the OS reserves the right of killing your app at any time.

Have the service start at boot

Impossible. Third-party applications cannot run automatically at boot on iOS.

This must be possible - apps like Facebook and Gmail start syncing as soon as the device finishes booting.

Given what stated above, I definitely can tell you that they don't. It might look like, but they cannot technically do that.

One option you have on iOS 7 is to have your app to refresh data in background when a special push notification is received, as discussed here. Long story short, you can send a push notification that triggers the data refresh and it's probably what Facebook and GMail do, in order to give the impression that the content was constantly updated in background.

like image 87
Gabriele Petronella Avatar answered Dec 28 '22 07:12

Gabriele Petronella


When your app is launched, it could begin updating / syncing Dropbox data in the background.

It is not possible to have a service that runs when the device boots. The Facebook app and Gmail app do not have a service / process that runs when the device boots.

like image 27
bbarnhart Avatar answered Dec 28 '22 07:12

bbarnhart