Newsstand loads after user closes application Completely

How to resume downloading after the user closes the application, and not just put it in the background?

My code looks like to start the download initially, I want to be able to identify here if the problem 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]; 
0
source share
1 answer

Well, that looks pretty simple. The way I'm doing it (and it seems Apple is speaking) is that the following code is used in the AppDelegate 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. It was briefly mentioned at WWDC 2011 under session 504. These videos and slides are good links to newsstands. I highly recommend you watch / read. It helped me a lot. Good luck

+3
source

Source: https://habr.com/ru/post/1393110/


All Articles