gpt4 book ai didi

ios - 不会为每个推送通知调用 didReceiveRemoteNotification

转载 作者:可可西里 更新时间:2023-11-01 04:41:53 24 4
gpt4 key购买 nike

似乎如果我同时向同一设备发送多个推送通知,则不会为每个发送的通知调用 didReceiveRemoteNotification。假设我发送了 6 个通知,didReceiveRemoteNotification 平均只被调用 3 次。那就是应用程序当前是否正在运行。但是,如果我在应用程序之外并发送 6 个推送通知,所有推送通知都会发送到通知中心/锁定屏幕。这是预期的行为吗?

最佳答案

这是预期的行为:

Apple Push Notification service includes a default Quality of Service (QoS) component that performs a store-and-forward function.

If APNs attempts to deliver a notification but the device is offline, the notification is stored for a limited period of time, and delivered to the device when it becomes available.

Only one recent notification for a particular application is stored. If multiple notifications are sent while the device is offline, each new notification causes the prior notification to be discarded. This behavior of keeping only the newest notification is referred to as coalescing notifications.

If the device remains offline for a long time, any notifications that were being stored for it are discarded.

虽然您的设备在线,但需要注意的重要一点是,APNs 只会为您的应用程序为每台设备存储一个通知。假设您一次发送 3 个通知。当第二条消息到达时,APN 服务器正在将第一条消息传送到设备。它存储第二条消息。然后第三条消息在第一条消息仍在传递时到达,因此第三条消息会覆盖第二条消息,而第二条消息永远不会传递。

这里是你可能会觉得更有说服力的另一句话:

Some Notifications Received, but Not All

If you are sending multiple notifications to the same device or computer within a short period of time, the push service will send only the last one.

Here's why. The device or computer acknowledges receipt of each notification. Until the push service receives that acknowledgment, it can only assume that the device or computer has gone off-line for some reason and stores the notification in the quality of service (QoS) queue for future redelivery. The round-trip network latency here is of course a major factor.

As described in the Local and Push Notification Programming Guide, the QoS queue holds a single notification per app per device or computer. If the service receives another notification before the one in the queue is sent, the new notification overwrites the previous one.

All of this points out that the intent is that a notification indicates to an app that something of interest has changed on the provider, and the app should check in with the provider to get the details. Notifications should not contain data which isn't also available elsewhere, and they should also not be stateful.

Any push notification that isn't delivered immediately was queued for future redelivery because your device was not connected to the service. "Immediately" of course needs to take latency for your connection into account. Outlying cases would be beyond 60 seconds as APNs will time out at that point.

Source

关于ios - 不会为每个推送通知调用 didReceiveRemoteNotification,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19662881/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com