问题
How do we resume a download after the user quits the app, not just put into background?
My code looks like this to start the download initially, I want to be able to identify here as to if the issue can be resumed.
NSMutableURLRequest *nkRequest = [NSMutableURLRequest requestWithURL:url
cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData
timeoutInterval:30.0];
NKLibrary *library = [NKLibrary sharedLibrary];
NKIssue *issue = [library addIssueWithName:[downloadInfo objectForKey:kPackageID] date:[NSDate date]];
[[NKLibrary sharedLibrary] setCurrentlyReadingIssue:[[NKLibrary sharedLibrary] issueWithName:[downloadInfo objectForKey:kPackageID]]];
NKAssetDownload *asset = [issue addAssetWithRequest:nkRequest];
[asset setUserInfo:[NSDictionary dictionaryWithObjectsAndKeys:info,@"info", nil]];
[asset downloadWithDelegate:self];
回答1:
Well, it seems to be quite simple. The way I am doing (and how it seems Apple says to do it) is by putting the following code in the AppDelegate method application:didFinishLaunchingWithOptions:
// Get the Library
NKLibrary *nkLib = [NKLibrary sharedLibrary];
// Loop through all 'queued' NKAssetDownloads and resume with a delegate
for(NKAssetDownload *asset in [nkLib downloadingAssets])
{
[asset downloadWithDelegate:yourDownloadDelegate];
}
That should be all you need to do. This was briefly mentioned at WWDC 2011 under Session 504. That video and slides are good Newsstand-Kit references. I would highly recommend you watch/read that. It helped me a lot. Good luck!
来源:https://stackoverflow.com/questions/8583652/newsstand-resume-download-after-the-app-closed-by-user-fully