1

NSURLSession provides the ability to run something under background with URLSessionDidFinishEventsForBackgroundURLSession and here is the simple intro

For networking layer, most iOS dev get used to build on AFNetworking or Alamofire, which is the most pop wrapper based on iOS URL loading framework.

Just wonder how is the background task running deeply, like sort of questions

  1. how to switch this ability on and off?
  2. how long it will run?
  3. any limits such as memory , time, security permission etc
  4. what is the common case which need background running capability?
vhu
  • 12,244
  • 11
  • 38
  • 48
Forrest
  • 122,703
  • 20
  • 73
  • 107

1 Answers1

0

While AFNetworking and Alamofire are the most two popular libraries for implementing networking on iOS, they both still require a solid foundational set of knowledge of the URL Loading System. I'd highly recommend you read through that article in detail. It explains many of the questions that you've posted. Additionally, any developer wishing to use AFNetworking or Alamofire should have a solid understanding of the concepts in that document before trying to use either library.

With that said, here are some more direct answers to your questions:

  1. Create the URL session with a background session configuration
  2. As long as you want
  3. No limits, the background task will run until it completes or errors out
  4. There are hundreds of cases where you may want to run in the background. Downloading images, videos, news feeds, updates, etc.
cnoon
  • 16,575
  • 7
  • 58
  • 66