苹果推送通知从APNS重新发送

时间:2021-07-13 02:19:24

From Apple's document I understand that if the device is offline, the APNS holds the last notification and sends it to the device when the device is back online. Is there is any mechanism to avoid that resending?

从苹果的文件中我了解到,如果设备离线,APNS会保存最后的通知,并在设备重新上线时发送给设备。有什么机制可以避免这种重新发送吗?

3 个解决方案

#1


6  

The answer is NO

答案是否定的

Here is what apple says about it,

这是苹果的说法,

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.

如果APNs试图发送通知,但设备处于脱机状态,则通知将被存储一段有限的时间,并在通知可用时交付给设备。

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.

如果设备长期处于脱机状态,则为其存储的任何通知都将被丢弃。

#2


16  

The correct answer is YES

正确的答案是肯定的

If you send notifications using the enhanced binary format (the one that includes message identifier and expiry), you can use the expiry parameter to prevent the notification from being stored in the APN server. This way the notification is delivered only if the device is online when the APN server first tries to deliver it.

如果您使用增强的二进制格式发送通知(包括消息标识符和到期时间),您可以使用过期参数来防止通知被存储在APN服务器中。这样,只有当设备在APN服务器首次尝试交付时处于联机状态时,才会发送通知。

Expiry

到期

A fixed UNIX epoch date expressed in seconds (UTC) that identifies when the notification is no longer valid and can be discarded. The expiry value uses network byte order (big endian). If the expiry value is positive, APNs tries to deliver the notification at least once. Specify zero (or a value less than zero) to request that APNs not store the notification at all.

以秒(seconds)表示的一个固定的UNIX纪元日期,该日期标识通知何时不再有效,并可以丢弃。过期值使用网络字节顺序(大端)。如果过期值为正值,APNs试图至少提交一次通知。指定0(或小于零的值)来请求APNs根本不存储通知。

#3


2  

I agree with Eran.

我同意伊兰。

This part of your question "the APNS holds the last notification and sends it to the device when the device is back online" is only true if Expiration date is different of zero.

您的问题“APNS保存最后的通知,并在设备重新联机时发送给设备”只有在过期日期与0不同时才为真。

If you do want the message to be delivered when the phone gets online, the message will wait until "Expiration date" before be discarded.

如果您确实希望在电话上网时发送消息,则消息将等到“过期日期”后才被丢弃。

APNS documentation:

apn文档:

Expiration date 4 bytes A UNIX epoch date expressed in seconds (UTC) that identifies when the notification is no longer valid and can be discarded. If this value is non-zero, APNs stores the notification tries to deliver the notification at least once. Specify zero to indicate that the notification expires immediately and that APNs should not store the notification at all.

过期日期4字节的UNIX纪元日期以秒表示(UTC),该日期标识通知不再有效且可以被丢弃。如果这个值是非零的,那么APNs将存储通知,并尝试至少交付一次通知。指定零,以指示通知立即过期,且APNs不应存储通知。

For more details, refer to https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/CommunicatingWIthAPS.html

有关详细信息,请参阅https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/CommunicatingWIthAPS.html

#1


6  

The answer is NO

答案是否定的

Here is what apple says about it,

这是苹果的说法,

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.

如果APNs试图发送通知,但设备处于脱机状态,则通知将被存储一段有限的时间,并在通知可用时交付给设备。

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.

如果设备长期处于脱机状态,则为其存储的任何通知都将被丢弃。

#2


16  

The correct answer is YES

正确的答案是肯定的

If you send notifications using the enhanced binary format (the one that includes message identifier and expiry), you can use the expiry parameter to prevent the notification from being stored in the APN server. This way the notification is delivered only if the device is online when the APN server first tries to deliver it.

如果您使用增强的二进制格式发送通知(包括消息标识符和到期时间),您可以使用过期参数来防止通知被存储在APN服务器中。这样,只有当设备在APN服务器首次尝试交付时处于联机状态时,才会发送通知。

Expiry

到期

A fixed UNIX epoch date expressed in seconds (UTC) that identifies when the notification is no longer valid and can be discarded. The expiry value uses network byte order (big endian). If the expiry value is positive, APNs tries to deliver the notification at least once. Specify zero (or a value less than zero) to request that APNs not store the notification at all.

以秒(seconds)表示的一个固定的UNIX纪元日期,该日期标识通知何时不再有效,并可以丢弃。过期值使用网络字节顺序(大端)。如果过期值为正值,APNs试图至少提交一次通知。指定0(或小于零的值)来请求APNs根本不存储通知。

#3


2  

I agree with Eran.

我同意伊兰。

This part of your question "the APNS holds the last notification and sends it to the device when the device is back online" is only true if Expiration date is different of zero.

您的问题“APNS保存最后的通知,并在设备重新联机时发送给设备”只有在过期日期与0不同时才为真。

If you do want the message to be delivered when the phone gets online, the message will wait until "Expiration date" before be discarded.

如果您确实希望在电话上网时发送消息,则消息将等到“过期日期”后才被丢弃。

APNS documentation:

apn文档:

Expiration date 4 bytes A UNIX epoch date expressed in seconds (UTC) that identifies when the notification is no longer valid and can be discarded. If this value is non-zero, APNs stores the notification tries to deliver the notification at least once. Specify zero to indicate that the notification expires immediately and that APNs should not store the notification at all.

过期日期4字节的UNIX纪元日期以秒表示(UTC),该日期标识通知不再有效且可以被丢弃。如果这个值是非零的,那么APNs将存储通知,并尝试至少交付一次通知。指定零,以指示通知立即过期,且APNs不应存储通知。

For more details, refer to https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/CommunicatingWIthAPS.html

有关详细信息,请参阅https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/CommunicatingWIthAPS.html