【问题标题】:Newsstand resume download after the App closed by user Fully用户完全关闭应用后报亭恢复下载
【发布时间】:2012-01-12 02:21:49
【问题描述】:

我们如何在用户退出应用后恢复下载,而不仅仅是进入后台?

我的代码最初看起来像这样开始下载,我希望能够在这里确定问题是否可以恢复。

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

【问题讨论】:

    标签: ios newsstand-kit


    【解决方案1】:

    嗯,这似乎很简单。我正在做的方式(以及 Apple 所说的做法)是将以下代码放入 AppDelegate 方法应用程序中: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 参考资料。我强烈建议您观看/阅读。这对我帮助很大。祝你好运!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-09
      相关资源
      最近更新 更多