Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
405 views
in Technique[技术] by (71.8m points)

urbanairship.com - Push notifications to Passbook via Urban Airship not appearing on device

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?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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:

  • Device receives push and queries web service with the passTypeIdentifier and lastUpadted tag
  • Web service provides a list of serials for all passes with the passTypeIdentifier that have changed since the lastUpdated tag
  • Device receives serial(s) and requests the web service to send the new .pkpass bundle for each new pass
  • Web service send the new .pkpass bundle
  • Device receives the .pkpass bundle and checks it against the old pass for changes
  • If the following criteria are met, the device will display the notification provided in the changeMessage key:
    • The value has changed
    • The changeMessage contains the %@ string

Id the %@ string is not present, the pass will show a notification Pass Changed. If no changeMessage key is present for the changed value, no message will show.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...