Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How long does a push notification sit in queue before being removed?

I've been digging around trying to uncover some data for apple's push notifications for a client and something I have been unable to find an answer to is how long a push notification will sit in queue for an offline device before it will be removed.

There maybe long periods of time, 2-3 months for example, in which the device maybe inactive and powered off. I'm simply interested in knowing how long I can expect a notification to linger, waiting to be delivered to an offline device, before it gets automatically removed (which is what I understand to be what happens).

like image 766
NicholasTGD Avatar asked Dec 22 '11 19:12

NicholasTGD


2 Answers

Official developer documentation isn't clear about this. From developer.apple.com:

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 QoS stores the notification. It retains only one notification per application on a device: the last notification received from a provider for that application. When the offline device later reconnects, the QoS forwards the stored notification to the device. The QoS retains a notification for a limited period before deleting it.

But according to PCWorld, it's 28 days:

If the app is running, it gets the notification immediately. If the app isn't running, the notification is held in the phone to be consumed at the app's next launch. If the iPhone is offline when the sender attempts delivery, APNS attempts to send the notification for 28 days.

While 28 days may have been true in 2009, I wouldn't be surprised if its different today. The ambiguity in the documentation is a great excuse for Apple to change this timeout period willy-nilly.

like image 52
calebds Avatar answered Oct 06 '22 06:10

calebds


Upon digging the docs I found out that we can use 'expiration date' parameter to control the queuing of APNS notifications.

Here is the detailed explanation on the usage of expiration date

apns-expiration

A UNIX epoch date expressed in seconds (UTC). This header identifies the date when the notification is no longer valid and can be discarded.

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. If the value is 0, APNs treats the notification as if it expires immediately and does not store the notification or attempt to redeliver it.

like image 3
avichalp Avatar answered Oct 06 '22 07:10

avichalp