djacobs / PyAPNs

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

change PayloadAlert to allow an alert which doesn't have any bodies #70

Closed co3k closed 10 years ago

co3k commented 10 years ago

The current implementation of PayloadAlert requires "body", but the alert attribute of payload doesn't require it like the following (this example is from https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html):

{
    "aps" : {
        "alert" : {
            "loc-key" : "GAME_PLAY_REQUEST_FORMAT",
            "loc-args" : [ "Jenna", "Frank"]
        },
        "sound" : "chime"
    },
    "acme" : "foo"
}

We can pass None to "body" of course but it uses wasteful bytes of payload. It is not good since the payload has length limitation.

co3k commented 10 years ago

My patch allows empty PayloadAlert as a result. Maybe it should be denied (by raising exceptions). Any comments?

hagino3000 commented 10 years ago

:+1: