Here is the question: how to download a number of files one by one using the new Background Transfer Service (including the case when the app is suspended)? I read this awesome tutorial on objc.io and got it working for one file. But I need to download files one by one (so adding multiple NSURLSessionDownloadTasks
s will not work (since download URLs are only valid for a short amount of time)
Basically what I am trying to do is to schedule another download once the app is notified that the previous download finished in application:handleEventsForBackgroundURLSession:completionHandler:
. But I only get this method invoked once. Any idea why? Any advice on how to implement sequential downloads for multiple files when the app is suspended is appreciated.
UPDATE:
Sorry, I probably was not clear about what the actual problem is: it's not that I do not get notified about the task completion in general, it's that I do not have application:handleEventsForBackgroundURLSession:completionHandler:
called for the second download task when the app is running in the backgorund. I do get it invoked for the first download task (which started while the app was in the foreground and then went to background before the download finished) then I fire the second download task, call the completionHandler
I got in application:handleEventsForBackgroundURLSession:completionHandler:
and never have this method invoked for the second file.