Monday, February 29, 2016

What are main APNS message headers

For sending APNS notifications, most of us rely on the third party libraries such as JavaPNS or pushy etc. Internally, these libraries are dealing with APS to send the notifications, 
Below are the main headers when communicating with the APS 

apns-id : A canonical UUID that identifies the notification. If there is an error sending the notification, APNs uses this value to identify the notification to your server.
    The canonical form is 32 lowercase hexadecimal digits, displayed in five groups separated by hyphens in the form 8-4-4-4-12. An example UUID is as follows:
    123e4567-e89b-12d3-a456-42665544000
    If you omit this header, a new UUID is created by APNs and returned in the response. 

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.

apns-priority : The priority of the notification. Specify one of the following values:
    10–Send the push message immediately. Notifications with this priority must trigger an alert, sound, or badge on the target device. It is an error to use this priority for a push notification that contains only the content-available key.
    5—Send the push message at a time that takes into account power considerations for the device. Notifications with this priority might be grouped and delivered in bursts. They are throttled, and in some cases are not delivered.
    If you omit this header, the APNs server sets the priority to 10.

content-length : The length of the body content. You must provide a value for this header, and the body length must be less than or equal to 4096 bytes. 

apns-topic  : The topic of the remote notification, which is typically the bundle ID for your app. The certificate you create in Member Center must include the capability for this topic.
If your certificate includes multiple topics, you must specify a value for this header.
If you omit this header and your APNs certificate does not specify multiple topics, the APNs server uses the certificate’s Subject as the default topic.

References:

No comments:

Post a Comment