iOS 应用程序是否可以以编程方式了解 APNS 警报何时到达设备?
我们有一个以通知为中心的应用程序,它通过 APNS 从服务器接收通知。服务器在时间 T0 发送警报。当应用程序不在前台时,iOS 将在时间 T1 使用任何一种通知样式(包括 iOS 5 中的警报或横幅样式)提醒用户。然后,用户单击通知,应用程序启动,我们使用通知负载中的详细信息在时间 T2 时从服务器等获取更多详细信息。
很容易识别 T0(将其包含在通知负载中)和 T2(在设备上可用)。有没有办法让应用程序以编程方式了解 T1 - 设备收到通知的时间?
We have a notification centric application which receives notifications from a server via APNS. The server sends the alert at time T0. When the app is not in the foreground, iOS will alert the user using any one of the notification styles (including Alerts or Banner style in iOS 5) at time T1. The user then clicks the notification, the app launches and we use the details in the notification payload to fetch more details from the server etc at time T2.
It's easy to identify T0 (include it in notification payload) and T2 (available on device). Is there a way for the application to programmatically know T1 - the time at which the device received the notification?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,没有 API 可以获取消息实际传送到设备的时间。
您知道 T1 的唯一情况是当应用程序位于前台时收到推送通知。然后 iOS 不会显示任何 UI,它只会调用应用委托上的
application:didReceiveRemoteNotification:
方法。 T1 与 T2 相同。No, there are no APIs to get the time of which the message was actually delivered to the device.
The only case where you know T1 is when you receive the push notification while the application is in the foreground. Then iOS won't show any UI for it, it'll just call the
application:didReceiveRemoteNotification:
method on your app delegate. And T1 will be identical to T2.