PHP Apple Enhanced Notification
I've been using [this excellent blog post][1] to try and get Apple Push Notifications working from my server. Connection seems to establish fine and I can write to it. However, no notification ever arrives. To try and debug it I'd like to construct an 'enhanced notification' which will make the APNS server return an error code before disconnecting. However, I'm unsure how to construct the data to send to the server using PHP.

Currently for a normal notification I am using, as per the tutorial post:

    $apnsMessage = chr(0) . chr(0) . chr(32) . pack('H*', str_replace(' ', '', $deviceToken)) . chr(0) . chr(strlen($payload)) . $payload;

This creates a request in the format:

![alt text][2]

However, I need a request in the format:

![alt text][3]

Where, according to the documentation:

Identifier—An arbitrary value that identifies this notification. This same identifier is returned in a error-response packet if APNs cannot interpret a notification.

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 should be in network order (big endian). If the expiry value is positive, APNs tries to deliver the notification at least once. You can specify zero or a value less than zero to request that APNs not store the notification at all.

Any help in adapting the above code to tuse the above enhanced notification format would be much appreciated!

  [1]: http://blog.boxedice.com/2009/07/10/how-to-build-an-apple-push-notification-provider-server-tutorial/
  [2]: http://i.stack.imgur.com/FcL2Y.jpg
  [3]: http://i.stack.imgur.com/aZXBA.jpg
PHP Apple Enhanced Notification
===

I've been using [this excellent blog post][1] to try and get Apple Push Notifications working from my server. Connection seems to establish fine and I can write to it. However, no notification ever arrives. To try and debug it I'd like to construct an 'enhanced notification' which will make the APNS server return an error code before disconnecting. However, I'm unsure how to construct the data to send to the server using PHP.

Currently for a normal notification I am using, as per the tutorial post:

    $apnsMessage = chr(0) . chr(0) . chr(32) . pack('H*', str_replace(' ', '', $deviceToken)) . chr(0) . chr(strlen($payload)) . $payload;

This creates a request in the format:

![alt text][2]

However, I need a request in the format:

![alt text][3]

Where, according to the documentation:

Identifier—An arbitrary value that identifies this notification. This same identifier is returned in a error-response packet if APNs cannot interpret a notification.

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 should be in network order (big endian). If the expiry value is positive, APNs tries to deliver the notification at least once. You can specify zero or a value less than zero to request that APNs not store the notification at all.

Any help in adapting the above code to tuse the above enhanced notification format would be much appreciated!

  [1]: http://blog.boxedice.com/2009/07/10/how-to-build-an-apple-push-notification-provider-server-tutorial/
  [2]: http://i.stack.imgur.com/FcL2Y.jpg
  [3]: http://i.stack.imgur.com/aZXBA.jpg