Skip to content

Commit

Permalink
basic newsstand support
Browse files Browse the repository at this point in the history
  • Loading branch information
djacobs committed Aug 27, 2012
1 parent 3265670 commit 87e6fc1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions apns.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def __init__(self, use_sandbox=False, cert_file=None, key_file=None):
"""
super(APNs, self).__init__()
self.use_sandbox = use_sandbox
self.use_newsstand = use_newsstand
self.cert_file = cert_file
self.key_file = key_file
self._feedback_connection = None
Expand Down Expand Up @@ -169,12 +170,13 @@ def __init__(self):

class Payload(object):
"""A class representing an APNs message payload"""
def __init__(self, alert=None, badge=None, sound=None, custom={}):
def __init__(self, alert=None, badge=None, sound=None, newsstand=None, custom={}):
super(Payload, self).__init__()
self.alert = alert
self.badge = badge
self.sound = sound
self.custom = custom
self.newsstand = newsstand
self._check_size()

def dict(self):
Expand All @@ -191,6 +193,8 @@ def dict(self):
d['sound'] = self.sound
if self.badge is not None:
d['badge'] = int(self.badge)
if self.newsstand:
d['content-available'] = self.newsstand

d = { 'aps': d }
d.update(self.custom)
Expand All @@ -204,7 +208,7 @@ def _check_size(self):
raise PayloadTooLargeError()

def __repr__(self):
attrs = ("alert", "badge", "sound", "custom")
attrs = ("alert", "badge", "sound", "content-available", "custom")
args = ", ".join(["%s=%r" % (n, getattr(self, n)) for n in attrs])
return "%s(%s)" % (self.__class__.__name__, args)

Expand Down

0 comments on commit 87e6fc1

Please sign in to comment.