What is the default value of the apns-expiration field?
Asked Answered
M

3

8

The apns-expiration field governs how long Apple will hold on to an apns message before giving up on delivering it (for example, if the device is turned off).

According to their docs, a value of zero means "no retention": meaning that if the message can't be delivered immediately, its discarded.

But what happens if the header isn't specified? In other words, what is the default behavior?

Medici answered 19/6, 2017 at 12:8 Comment(6)
Good question. I see nothing about it in the docs. For the old binary "enhanced" format, the expiration value was part of the expected binary message, so it always had a value.Wrought
@Eran: perhaps you know - the very first version of apns (pre 'enhanced') did not explicitly specify expiration date. Perhaps you know what the retention default for that is?Medici
I guess I could just test it.Medici
I have no idea.Wrought
Good question, but I would advise never rely on something which is not documented. Behavior can change anytime & can make your app suffer. You can always set expiration as '0' for real time notifications which doesn't make sense to be delivered later. :)Loyceloyd
@ayush - you're right. its not a good practice. However sometimes you're facing a legacy system that does just that... :]Medici
M
3

My information isn't based on documentation but rather on stats gathered from a multi-million users system. The policy at this time is to retain push messages for a long time (exactly how long I dont know - we've seen 1M seconds retention in some cases). Of course, as this isn't documented it could change in the future.

Note that this default value is similar to Google's policy (where the default is 2419200 seconds), with the exception that Google's policy is documented.

Medici answered 28/6, 2017 at 6:47 Comment(1)
Based on this answer it can be really 28 days, unfortunately the link is dead. apple.stackexchange.com/a/364488 Since FCM can only hold notification for 28 days and that is also the said default value when not specified if that is the case then that will be the possible default value if you are using FCM.Atlanta
M
1

According to the new Apple Docs, for no specified expiration date the notification is stored and retried for upto 30 days.

Maritime answered 25/6, 2023 at 13:0 Comment(0)
P
-1

https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html#//apple_ref/doc/uid/TP40008194-CH11-SW1

"If this value is nonzero, APNs stores the notification and tries to deliver it at least once, repeating the attempt as needed if it is unable to deliver the notification the first time."

Literally this means that the absence of the value equals to 0.

Promote answered 9/12, 2021 at 13:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.