Download resuming failed in NSUrlSession on iOS10

I implemented a background downoading feature in my application, during test I discovered that background downloading is not resuming in iOS 10 only. Code worked well on previous version (below iOS 10). I could not find any solution for this issue.


When Internet is down then in "didCompleteWithError" delegate I add this code to cancel by producing Resume Data


-(void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error{


[self.fdi.downloadTask cancelByProducingResumeData:^(NSData *resumeData) {

taskResumeData = (NSData *)[[error userInfo]objectForKey:@"NSURLSessionDownloadTaskResumeData"];

}];


}


After Internet connection avaible I call this method - (NSURLSessionDownloadTask *)downloadTaskWithResumeData:(NSData *)resumeData; for resuming downloading using resumedData.



downloadTask = [APP_DELEGATE.downloadManager.session downloadTaskWithResumeData:taskResumeData];

[downloadTask resume];





After calling above method we get this error:



Error on cosole:


2016-09-20 17:28:04.126863 BigFlix[3253:591639] -[NSKeyedUnarchiver initForReadingWithData:]: data is NULL

2016-09-20 17:28:04.127684 BigFlix[3253:591639] -[NSKeyedUnarchiver initForReadingWithData:]: data is NULL

2016-09-20 17:28:04.419939 BigFlix[3253:591639] Invalid resume data for background download. Background downloads must use http or https and must download to an accessible file.

Replies

Same issue, here still exists in 10.1.

Right, because, as I mentioned in my Nov 1 post, this issue “is reported as fixed in the current 10.2 beta seed”. Customers won’t see this fix until 10.2 GMs.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

I have this bug too. It's been plaguing iOS 10 the whole time. And I've tried every last fix I could hunt down. I'm now going to switch to the All Seeing Eye which is what we all used to use five years ago before Apples automatic downloading system. Good luck guys!!!

I'm now going to switch to the All Seeing Eye which is what we all used to use five years ago before Apples automatic downloading system.

I don’t see how that will help. This bug’s impact is primarily on background sessions (it affects standard sessions, but it’s possible to work around it in that context) and there’s no other way to get background downloads.

Moreover, a big change to your app seems unwarranted given that the fix is in 10.2, which is now shipping to customers.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"