Tuesday, February 5, 2013

APNS and PHP gotcha...

This got me good.  Wondering why your APNS messages aren't delivered?  And there's no error message from your client?  Well now, print out the APS payload after it has been JSON encoded.  A correct message should look like this:

{"aps":{"alert":"Oh really?","badge":1,"sound":"default"},"message_type":"message"}

Compare that to a message which supposedly looks fine but doesn't get sent:

{"aps":{"alert":"Ughieness:nfng","badge":"1","sound":"default"},"message_type":"message"}

See the difference? :)

Yup, the "badge" value.  PHP cast the "badge" value to a string :(  Blogging this so that I don't crack my head in the future.