Resuming Data..
harishBms opened this issue · 6 comments
Hi,
Really appreciate for creating this kind of wrapper.I had a doubt,how can i save the data and resume the downloading.Could you please help me out,
Thanks in adavance.Cheers
Hi, since the background download task is managed by the iOS system, you don't need to resume the download in most cases. When you close the app, the download continues in the background. When you reopen it, it's the same. Moreover, If you add [FLDownloader sharedDownloaer]; in the AppDelegate as specified in the readme, the shared Downloader instance fetch for active downloads and start to send the progress callbacks again. The only situations where the downloads need to be restarted are when the app is killed by the user (with the multitasking bar). in this situation, the download session is terminated. FLDownloader takes a list of the outstanding downloads and, when started again, restarts the terminated download again (with the two calls added in the AppDelegate ad specified in the readme). The only "problem" is that these downloads are started from the beginning, because I didn't find a simple way to produce resume data when the app is killed by the user (the app is killed immediately without delegate callbacks). I'll look for a solution in the next days
After a fast check, it seems that, when the app is killed in background by the user (and the download are terminated), at the next launch a call to
- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error
is made, passing the resume data inside the userinfo of the error.
I'll use it in the next release to resume the download from the last point ;-) if you need it immediately feel free to modify my code (and to send your updates, if you want)
Oh okay..thanks for the reply..i'll check it out..can i have your gmail or Skype id..so that i can be in touch with you regarding this.
Everything is fine except we need to implement this download resuming.Yup i could see the data in [error userInfo].I'll quickly modify the code and get back to you.
My e-mail is lombax85@gmail.com.
I updated the code to include the resume of a killed download task, it's quite simple. Look in FLDownloader the changes in the method
- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didCompleteWithError:(NSError *)error
Hi,
Harish here..Thanks a lot for the reply....yeah i did make this change..it was pretty simple..but the problem is download is not resuming when i kill the app manually from the task manager..if the app is killed by ios(say if you are running this code on Xcode and starts the download and stops the app.When you open it did resume downloading.).but when you kill the app manually..its not resuming.....
Please run the app on device,start the download ,quit it from task bar ,reopen the app and check the download resuming for better understanding..
Thanks and Regards,
Harish