Should I call setMinimumBackgroundFetchInterval every time the app restarts?
Asked Answered
W

1

5

I developed an app that uses background fetch. I set the minimum interval between updates to minimum:

[[UIApplication sharedApplication] setMinimumBackgroundFetchInterval:UIApplicationBackgroundFetchIntervalMinimum];

I thought that this value is saved by the system, so I don't have to set it again when/if the app restarts. However, I've just noticed that the last background fetch on one of my devices was two weeks ago. I know, that the interval between updates can vary, but I don't think that two weeks is normal. Especially considering the fact that it worked for several months, calling background update every 20-30 minutes.

Unfortunately, I couldn't find a way to get the MinimumBackgroundFetchInterval to check my theory (does anyone know how to get it by the way?). I only checked application.backgroundRefreshStatus, and it is equal to UIBackgroundRefreshStatusAvailable, but I think (I'm not sure) this only means that the user allows the app to use background updates.

Woundwort answered 14/4, 2015 at 20:7 Comment(0)
W
9

Well, it turned out that NO, we don't need to call setMinimumBackgroundFetchInterval every time the app restarts.

I had an experiment: I set it to UIApplicationBackgroundFetchIntervalMinimum (turned the background fetch on), then shut the app down manually (via the task manager) and then restarted it, but didn't call to setMinimumBackgroundFetchInterval. The app continued to perform background fetches as it used to.

I hope, that this information will be helpful for someone, since it is not explicitly stated in the documentation (at least, I didn't see it). As for me, I have to find another possible reason why my app didn't work for two weeks.

Woundwort answered 15/4, 2015 at 18:18 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.