Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

basic newsstand support

  • Loading branch information...
commit 87e6fc146230930a1ec348ac1b322e86f7cae42e 1 parent 3265670
@djacobs authored
Showing with 6 additions and 2 deletions.
  1. +6 −2 apns.py
View
8 apns.py
@@ -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
@@ -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):
@@ -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)
@@ -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)
Please sign in to comment.
Something went wrong with that request. Please try again.