djacobs / PyAPNs

Python library for interacting with the Apple Push Notification service (APNs)
http://pypi.python.org/pypi/apns/
MIT License
1.22k stars 374 forks source link

Passbook APN Payload is easy but different #28

Closed timtan closed 8 years ago

timtan commented 11 years ago

I add a Passbook Payload, so it can be used explicitly for passbook developers.

timtan commented 11 years ago

Here is the documentation from Passbook Programing guide we need to provide en empty json for passbook update

ExplodingCabbage commented 8 years ago

Docs link above is broken; I think the pertinent docs are now located at https://developer.apple.com/library/ios/documentation/PassKit/Reference/PassKit_WebService/WebService.html.

Passbook notifications seem to be unchanged; this quote still exists:

Any time the pass is updated, your server sends a push notification with an empty JSON dictionary as the payload to the device using the given push notification token.

Hence, nothing has changed in the last 3 years to invalidate this pull request.

However, I'm not sure this implementation is correct? It's unclear what "with an empty JSON dictionary as the payload" means. As described at https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/TheNotificationPayload.html#//apple_ref/doc/uid/TP40008194-CH107-SW1 and implemented currently in PyAPNs, the payload of a normal notification has everything nested under the "aps" key. So with Passbook notifications, are we supposed to send a payload of {} or of {"aps": {}}? Both seem like reasonable interpretations of the docs, which in typical Apple style manage to be simultaneously hugely verbose and lacking in clarity on key details.

To add to the confusion, the CTO of PassKit has a post of Stack Overflow in which he says this (sic):

The payload should be an empty - E.g. {"aps":""}

Obviously, there is no empty dictionary anywhere in the above code, which contradicts the Apple docs!

This means that, based upon what's been written in official sources, there are three reasonable things that the .json() method of a PassbookPayload could return:

I have no idea which of these work and which don't.

@timtan did you actually use this code in production successfully? I don't have an iOS device to test on at present.