I've found this post to be really helpful in getting set up, but I have yet to see the push notification come through on the iPhone on which the pass is installed.
Passkit-push-notification-not-working-with-urban-airship
I set up my app on urban airship's site pushing to Apple's development servers. I installed a pass on my phone and run the following commands which I found in the above post:
airship = urbanairship.Airship(_UrbanAirshipPassbookKey, _UrbanAirshipPassbookMasterSecret)
airship.push({'aps': {'alert': 'Go.'}}, device_tokens=tokens)
I then see confirmation of this push in the iPhone console window in Xcode.
Received push for topic pass.xxx.xxx: {
...
aps = {
banner = "Hello";
};
and the iPhone then sends its update tag back along with its pass type ID and Device Library ID to the web service. At this point the web service is supposed to send back a list of changed passes. However, I instead see the following error message:
<Warning>: Web service error for pass.mypasstype.id (http://192.168.30.209:8000): Response to 'What changed?' request included 1 serial numbers but the lastUpdated tag (2013-02-11T17:25:25) remained the same.
Does anyone know why this is happening? Do I need to actually modify a field in the pass to get the push notification to appear on the device?
The short answer to your question is yes, you do need to modify a field in the pass to get a push notification to show. This is because, unlike with app pushes, a Passbook push payload does not determine the content of the notification.
The purpose of a Passbook push message is to alert the device that the web service has a new pass with updated content. The alert text is determined solely by the new pass contents. Any content in the push payload is ignored. Apple advise a push notification with an empty JSON dictionary.
Once a push is sent, it triggers the following chain:
passTypeIdentifier
andlastUpadted
tagpassTypeIdentifier
that have changed since thelastUpdated
tagchangeMessage
key:changeMessage
contains the %@ stringId the %@ string is not present, the pass will show a notification
Pass Changed
. If nochangeMessage
key is present for the changed value, no message will show.