I was wondering whether it was possible to resume a download after the app has been terminated by the user or the OS.
I can see that SKTDownloadManager
has methods to pause and resume a download. However, these methods only work for current SKTDownloadObjectHelper
s.
If I pull them out of SKTDownloadManager.storedDownloadObjects()
after the app has been quit and then started again and throw them at SKTDownloadManager.sharedInstance().resumeDownloadForDownloadHelper()
the manager won't resume the downloads.
I dug a little deeper into the code and that these downloads are not getting restarted is because of a lack of a proper status. SKTGroupedDownloadOperation.m:87
:
if (self.currentRunningGroupedOperation.stateDownloadItem >= SKTMapDownloadItemStatusDownloading) {
return NO; //cannot start download,isntall, finsihed
}
So, my questions is whether it is even possible to resume downloads after the app has been terminated and if so how do I do it. Any help is appreciated :)
For resuming the download, you should trigger an event in the application:didFinishLaunching
or after the application restarted:
[[SKDownloadManager sharedInstance] tryRestartDownloadsWithDelegate:self andDataSource:self];