3 Replies
      Latest reply on Feb 16, 2020 9:17 AM by eskimo
      pdewaalSS Level 1 Level 1 (0 points)

        I am working on an application that needs to upload a large number of files to a server and would prefer to do this in the background to not impact the user experience.

        I've read up on all the new ios 13 BGTasks (processing and app refresh) and after downloading the example project from Apple (color feed) and other projects from 3rd parties trying to show how to implement it; none of the projects are working and the tasks are never getting called. I've tried everything I could think of and all permutations of having the device plugged in or not and setting the tasks to need power/network or not and have not gotten a single successful trigger of either an app refresh or a processing task. The documentation by Apple is rather lacking and the only real direction we are given is to simulate a trigger using the console.

        So my question is, are these tasks even useful for uploading data in the background (as I assumed the processing task would be) or is there a better method of it? Or is uploading of files in the background just not something iOS really allows?

        • Re: Proper method of uploading large amounts of files in the background
          eskimo Apple Staff Apple Staff (12,975 points)

          It is possible to using BackgroundTasks framework to run network requests.  Specifically, BGProcessingTaskRequest is useful in situations where you can’t use the follow.  But…

          In general, I recommend using an NSURLSession background session for background transfers.  The API has been around for a long time and it’s specifically designed for this networking use case.

          Share and Enjoy

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

            • Re: Proper method of uploading large amounts of files in the background
              pdewaalSS Level 1 Level 1 (0 points)

              In this case I've got a few things working against NSURLSession. 1) We have a large number of uploads (images/videos/etc) that we cannot do in bulk, and the guidelines mention using less background sessions and instead make them larger and 2) We are using the Firebase SDK for our uploads and they don't seem to have a configurable way to set the uploads as needing to use the background NSURLSession.

              Which is why I was really excited to learn about BGProcessingTasks, but then equally dismayed when nothing I did ever triggered them. How can I give my processing task the best chance of getting run?