4

I am instantiating a NSURLSession to do several background uploads like this:

  sessionConfiguration = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:myIdentifier];

Everything seems to work OK for the most part, but I am wondering if I need to add in the p.list the background Fetch key if all I am doing is background uploads and not downloads?. I am not able to find documentation saying that I should or that I should not. Specifically on XCode 5 +, I would like to know if under Capabilities>Background modes, I should enable or not background fetch, if all I am doing is background uploads, note that I do read the response after the upload is complete, which could be considered a "download".

Oscar Gomez
  • 18,102
  • 12
  • 80
  • 113

1 Answers1

5

The official guide Background Execution declare three type of background executions:

  1. Executing Finite-Length Tasks - using UIApplication method
    beginBackgroundTaskWithName:expirationHandler: to execute finite time task.
  2. Downloading Content in the Background - using NSURLSession to download content. The NSURLSession provided by your app is run on separate system level daemon and when done, gets back to the app by the completion handler. (Your above mentioned implementation)
  3. Implementing Long-Running Tasks - Tasks that needs to be running for long time, are handled under this category, like audio, voip, location, download processes, update contents. These type of tasks needs the special UIBackgroundModes key mentioned in info.plist.

So answering your question, you don't need the UIBackgroundModes key, until you don't fall in the long-running tasks category.

Adil Soomro
  • 36,617
  • 9
  • 98
  • 146