Hello, I have asked some difficult questions here, and got no valid response. So , right now I should really get some real help. The problem is that I am creating network request which uploads 6 photos. As soon as I startNetwork request I open anotherViewController and go to background and return, my request is killed and I am getting an error, that connection is interrupted. I learned about background task and this is what I have created:
let config = URLSessionConfiguration.background(withIdentifier: "test") let session = URLSession(configuration: config) let upload = session.uploadTask(with: URLRequest(), from: Data()) { (data, response, error) in // Completion }
Still I have removed all closures and I am getting an exception:
Terminating app due to uncaught exception ‘NSGenericException’, reason: ‘Completion handler blocks are not supported in background sessions. Use a delegate instead.’
How can I make sure that if user started uploading photos, goes to background and returns, that request is not killed and will continue???
I have read all articles, no information in website… If there are better ways to do that, please share.
I am doing this in framework, so I don’t have device requirements in target project