【问题标题】:Newsstand daily update content at background报亭每日更新内容在后台
【发布时间】:2014-08-11 02:53:45
【问题描述】:

我的应用程序应该每天自动下载报亭内容,但只有在我正常启动应用程序时才会启动。我对使用 Newsstand 应用程序完全陌生。我错过了什么吗?

我在后台模式的功能中勾选了“报亭下载”。

Info.plist

<key>UIBackgroundModes</key>
<array>
    <string>newsstand-content</string>
</array>

我将其放入 didFinishLaunchingWithOptionsdidReceiveRemoteNotification

NSString *issueName = [pdf lastPathComponent];
NKLibrary *library = [NKLibrary sharedLibrary];

if (![library issueWithName:issueName]) {
    NKIssue *issue = [library addIssueWithName:issueName date:pdf.newsDate];

    NKAssetDownload *asset = [issue addAssetWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:pdf.pdf]]];
    [asset downloadWithDelegate:self];

}

有什么好方法可以测试吗?我目前每天都在等待是否在不点击它的情况下更新应用程序(在后台运行)我认为这是一种愚蠢的方式。

【问题讨论】:

    标签: ios background newsstand-kit uibackgroundtask


    【解决方案1】:

    如果您想在测试期间测试报亭推送,只需输入此代码

    [[NSUserDefaults standardUserDefaults] setBool:YES  forKey:@"NKDontThrottleNewsstandContentNotifications"];
    [[NSUserDefaults standardUserDefaults] synchronize];
    

    在您的 App Delegate 中或在您初始化报亭服务时。这将确保 Newsstand-Kit 不会限制您的应用接收通知(如果您未设置此选项,则限制为每 8 小时推送 1 次)。

    我还建议您在 documentation 上搜索一下,以更好地了解报亭集成。您的推送通知可能不是报亭推送的预期类型,它们需要具有值为 1 的 key content-available。有关更多信息,您可以阅读Technical Note

    此外,请确保您的实际设备已为您的应用启用后台刷新(假设 iOS 7.0),否则报亭可能无法工作。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-28
      • 2012-03-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多