Search code examples
iosbackground-process

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.


Solution

  • 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.