7

In iOS 7, a background fetch mode is supported for apps to fetch data when the app is not frontmost:

When it is convenient to do so, the system launches or resumes the app in the background and gives it a small amount of time to download any new content.

My question is: how often is the background fetch code executed?

If I set the minimum interval:

[[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:10];

Does it get execute every 10 seconds, or maybe once a day? What kind of interval should I expect, generally?

NeoWang
  • 17,361
  • 24
  • 78
  • 126

1 Answers1

5

There is no way for you to know how often, it is up to things like the users usage pattern, device battery and whatever else Apple has in their algorithms...

The minimumBackgroundFetchInterval can be used to specify that your app doesn't need to run fetch so often, it does not make the fetch happen more often. You also have the minimum possible value in UIApplicationBackgroundFetchIntervalMinimum, which is what you can use if you want the background fetch to run as often as possible (but still no guarantee on how often it will actually run).

osanoj
  • 1,035
  • 10
  • 9
  • 4
    I understand. I am just wondering if anyone know the approximate frequency for an average app. Say if this app is launched once every day by user, and battery is not low, how often can I expect the fetch to happen? – NeoWang Mar 19 '15 at 15:36
  • I don't think there is any general frequency here (but if anyone knows more please correct me). If I understand correctly it might happen more often if the user uses the app regularly. It might also matter how quick and efficient the app generally is at doing the background fetch and how often you successfully fetch new data (there is a parameter for telling iOS the fetch result when you are done). – osanoj Mar 20 '15 at 08:58