Setting the request’s earliestBeginDate
is equivalent to the old minimum fetch interval. Just use earliestBeginDate
like you have seen in those other questions. And when your app runs a background fetch, you just schedule the next background fetch with its own earliestBeginDate
at that point. That is how BGAppRefreshTask
works.
If you are asking what is equivalent to UIApplication.backgroundFetchIntervalMinimum
, you can just set earliestBeginDate
to nil
. The documentation tells us that:
Specify nil
for no start delay.
Setting the property indicates that the background task shouldn’t start any earlier than this date. However, the system doesn’t guarantee launching the task at the specified date, but only that it won’t begin sooner.
The latter caveat applies to backgroundFetchIntervalMinimum
, too. Background fetch, regardless of which mechanism you use, is at the discretion of the OS. It attempts to balance the app’s desire to have current data ready for the user the next time they launch the app with other considerations (such as preserving the device battery, avoiding excessive use of the cellular data plan, etc.).
The earliestBeginDate
(like the older backgroundFetchIntervalMinimum
) is merely a mechanism whereby you can give the OS additional hints to avoid redundant fetches. E.g., if your backend only updates a resource every twelve hours, there is no point in performing backend refreshes much more frequently than that.