- watchOS 3.0+
Always upload and download data using an
URLSession background transfer. Background transfers occur in a separate process. They continue to transfer the data even after your app has terminated. Asynchronous uploads and downloads, on the other hand, are suspended with your app. Given the short run time of watchOS apps, you cannot guarantee that an asynchronous transfer will finish before the app is suspended. For more information on background transfers, see Background Transfer Considerations.
Do not subclass or create instances of this class yourself. Instead, the system instantiates a
WKURLSession object, and passes the task object to your extension delegate’s
handle(_:) method in response to
URLSession events. The system creates a background
URLSession task when any of the following events occur:
Authentication is required to complete a background transfer.
All background transfers associated with a session identifier have completed (either successfully or unsuccessfully).
To get more information about the transfer, create a background configuration object with the same session identifier. Next, create a session object using the configuration object and a session delegate. The new session is automatically reassociated with the transfer, and the appropriate delegate methods are called.
You will need to defer calling the background
set method until after you are done processing these delegate method calls.