用户完全关闭应用程序后,报亭恢复下载 [英] Newsstand resume download after the App closed by user Fully

查看:84
本文介绍了用户完全关闭应用程序后,报亭恢复下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们如何在用户退出应用程序后继续下载,而不仅是在后台运行?

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];

推荐答案

好吧,这似乎很简单.我的操作方式(以及苹果所说的方式)是通过将以下代码放入AppDelegate方法应用程序中:didFinishLaunchingWithOptions:

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];
}

这应该是您需要做的.在WWDC 2011的Session 504下对此进行了简要提及.该视频和幻灯片是不错的Newsstand-Kit参考.我强烈建议您观看/阅读.这对我帮助很大.祝你好运!

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!

这篇关于用户完全关闭应用程序后,报亭恢复下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆