1 Reply
      Latest reply: Jan 20, 2017 9:22 AM by eskimo RSS
      antipex Level 1 Level 1 (0 points)

        We have an app which makes various network requests – uploading and downloading media, quick reply, etc... – and they must continue in the background when the user switches away from the app. Is there any reason why we shouldn't use a background NSURLSession for all requests? Are there any downsides?

        • Re: Is there any reason to not use a background NSURLSession for all requests?
          eskimo Apple Staff Apple Staff (6,250 points)

          Is there any reason why we shouldn't use a background NSURLSession for all requests?

          Background sessions have a number of drawbacks:

          • They are significantly slower

          • They require more bookkeeping on the part of the system

          • They don’t support certain types of requests

          In general I recommend that you use background sessions for large transfers, and use a standard session for general work.

          Remember that, if the user switches away from your app, you can continue the request in the background by using a UIApplication background task to prevent the app from being suspended.  The exact amount of time you get depends on various factors, including the OS version, but you can reasonably expect to get a few minutes.  Most general networking requests will either finish or fail in that time.

          Share and Enjoy

          Quinn “The Eskimo!”
          Apple Developer Relations, Developer Technical Support, Core OS/Hardware
          let myEmail = "eskimo" + "1" + "@apple.com"