I have NSURLSession that is downloading multiple files. I'm updating an ios 7 application for ios 8. It works fine in ios 7, but when complied against ios 8 The delegate meathod
URLSessionDidFinishEventsForBackgroundURLSession:
is never called.
I dug a little deeper and on the
-(void)URLSession:(NSURLSession *)session downloadTask:(NSURLSessionDownloadTask *)downloadTask didFinishDownloadingToURL:(NSURL *)location
and
-(void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error
delegate meathods I am checking the session for the remaining download tasks:
[self.session getTasksWithCompletionHandler:^(NSArray *dataTasks, NSArray *uploadTasks, NSArray *downloadTasks){ ...}
On the last delegate meathod called there is always one element remaning in the downloadTasks array. What is strange is that this download task is not always referencing the same file, and the status on that tasks shows that the download is complete.
Again, works fine in ios7. Problem occurs in ios 8 only.
I presume you are testing on the iOS Simulator. If yes, another bug is responsible for this misbehavior. iOS8 Simulator never truly backgrounds apps, hence the completion handler won't trigger.
Try running on the device and it will work.
You can find a full discussion in the Apple forums or on this blog post
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With