1

I'm working on an iOS application which had Background Fetch enabled via the Info.plist for around a year. There were multiple versions released with background fetch enabled, but then a few weeks ago the feature that necessitated background fetch was removed. The UIBackgroundModes key was removed completely from the Info.plist, and the app was released to the App Store. Surprisingly though, telemetry indicated that the application was still being launched in the background periodically! This is a snippet from the actual app delegate source code:

- (void)application:(UIApplication *)application performFetchWithCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
    // NB: this callback should NEVER happen! But if it happens, we want to know about it.
    ... send telemetry log here ...
    completionHandler(UIBackgroundFetchResultNoData);
}

Has anybody experienced anything similar? According to the documentation, it should be impossible for the app to be launched if the UIBackgroundModes dictionary don't contain the right values. In this case, there's no background mode turned on at all, yet the app is periodically launched in the background to perform the fetch...

Telemetry data indicates that it happens on iOS 11 only, but that might be a coincidence because only a small fraction of the installed base is on iOS 9/10.

BTW a source level assistance request was sent to Apple with this issue, but they haven't replied yet; but maybe developers of other apps have encountered this issue before.

Tamás Zahola
  • 9,271
  • 4
  • 34
  • 46
  • I assume you're absolutely positive that the telemetry data comes from the most recent version of the app, i.e. the one without the background modes? Keep in mind that some users don't use auto-update and might "stay behind" a version. – Gero Apr 25 '18 at 11:09
  • Oh, I completely forgot about this! We've opened a code level assistance ticket at Apple, and their engineers told us that iOS "speculatively" pre-launches apps in the background to make them load faster when the user actually taps on the icon. They didn't elaborate the exact algorithm behind this speculative pre-launch, but we've been experiencing them whenever we pushed out an update, so it seems to be happening when an app is auto-updated by the system. – Tamás Zahola Apr 25 '18 at 15:40
  • Ah, I see. That's an interesting thing then, thanks for clarifying that (I have no idea how I got to your question, I didn't notice it's a bit older already. Glad you figured it out in the meantime, maybe this also helps somebody else in the future!) – Gero Apr 25 '18 at 18:22

0 Answers0