objective-c - 报亭套件推送通知而不使用应用程序如何获取用户信息

标签 objective-c ios push-notification newsstand-kit

我正在构建一个 Newsstand 应用程序,我想在后台下载最新一期。我设置了适当的后台模式键以允许这样做。

我将负载推送到我的应用程序,例如:

{"aps": {"badge": 1,"content-available":"1"}}

但如果我的应用程序不在前台,我怎么知道推送通知已发送以便我可以开始后台下载?如果应用程序在前台,我使用 didReceiveRemoteNotification: 但是当应用程序不在前台或什至没有运行时,我不知道该怎么做。

根据文档:

If an application is not running in the foreground when the notification is delivered, it is activated in the background (or launched into the background, if necessary) to download issue assets. Otherwise, you handle the notification as you would any push notification. See Local and Push Notification Programming Guide for information on how to send and handle push notifications.

The client application communicates with its server and gets URLs locating the issue assets to download. It might also need to obtain the name and date of the issue from the server. In this phase it might also validate that the user is eligible for a subscription or perform any other required authorization.

但它从未说明使用哪种方法开始下载。

最佳答案

只有当用户启动应用程序以响应推送通知(例如,在锁定屏幕上或从通知中心滑动它),或者如果它已经在运行时,您的应用程序才会收到推送通知。此外,不保证推送通知一定会送达。

更新:

正如您提到的,对于 Newstand 应用,您应该使用 UIRemoteNotificationTypeNewsstandContentAvailability 权限来启用后台下载新刊物。然而,这并非没有它自己的一系列技术挑战:

"...your app may only initiate a background download once every 24 hours. iOS will ignore notifications that try to initiate a background download more than once in a 24 hour period."

Can users disable background downloading?

Yes, users can disable Newsstand's push notification-initiated background downloading on a per-app basis in Settings. You can determine whether background downloading has been disabled for your app by looking for UIRemoteNotificationTypeNewsstandContentAvailability in the set of enabled types returned by UIApplication's enabledRemoteNotificationTypes property.

来自:http://developer.apple.com/library/ios/#technotes/tn2280/_index.html

完全有可能是在测试期间,您全天发送了过多的内容更新。

关于objective-c - 报亭套件推送通知而不使用应用程序如何获取用户信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13960889/

相关文章:

javascript - 在 Android/iOS 中通过浏览器发送推送通知

iOS:当应用程序进入后台调用电话时,如何防止启动画面显示?

ios - 如何为 didReceiveRemoteNotification 生成组合发布器?

android - 客户端未收到主题服务器端的 FCM 通知

javascript - 如何使 JQuery 步进器/微调器按钮在按下时更快地通过列表?

javascript - React Native 中动画完成时触发函数?

ios - 当特定用户发帖时解析推送通知

objective-c - 分离 SQLite 数据库时出错 - 数据库已锁定

iphone - 如何跨 View Controller 共享 UIView 和其他元素?

ios - 想通过xcode开启定位服务