Push notifications to Passbook via Urban Airship not appearing on device

时光毁灭记忆、已成空白 提交于 2019-11-30 09:08:59

问题


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?


回答1:


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.



来源:https://stackoverflow.com/questions/14839943/push-notifications-to-passbook-via-urban-airship-not-appearing-on-device

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!