Let’s say I have a hundred of big files to upload to a server, using requests with a short-lived authorisation token.
NSURLSession background upload describes a problem with adding too many requests, so the first question is: should we manage uploads manually, by which I mean queuing, postponing, retrying. Will we then fall into the same traps only in a different way?
What to do if tasks picked by the system have outdated token, and so fail. How to update a token: is there a delegate method (preferable pre iOS 13 compatibile) in which I can get a fresh token and modify a request header?
Is there any iOS specific design pattern or contract (Apple's list of server requirements) that would allow uploads to be resumable?
There are a couple of things you can do here:
-
Use a background processing request to request a significant amount of runtime (which you’ll typically get at night, when the device is on both Wi-Fi and power) and run all your requests in a
URLSession
standard session. -
Continue using a background session and experiment with the
urlSession(_:task:willBeginDelayedRequest:completionHandler:)
delegate callback.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"