In my app, I need to send a sequence of 4 requests. Requests need to be sent in order one after another.
- Request 1 - regular HTTP POST request to the backend
- Request 2 - file upload
- Request 3 - file upload
- Request 4 - regular HTTP POST request to the backend
This sequence needs to work in the background. I know that on iOS there's URLSession.uploadTask method that allows uploading files in the background.
Let's say that the user starts the sequence of requests, and then background the app right away.
- Can I make regular HTTP requests using URLSession.uploadTask method?
- When URLSession.uploadTask will finish while the app is in the background and the delegate method
func urlSession(_ session: URLSession, task: URLSessionTask, didCompleteWithError error: Error?)
will be invoked, can I start another URLSession.uploadTask inside this delegate method, so that all 4 requests will be run in the background?
- Is URLSession.uploadTask the right approach to run all 4 requests in the background?