Skip to content

Commit

Permalink
Merge pull request #174 from itsanand/master
Browse files Browse the repository at this point in the history
iOS 10 mutable-content support.
  • Loading branch information
djacobs committed Aug 29, 2016
2 parents 0edb297 + 886708a commit cee961b
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -3,3 +3,4 @@ build
dist
.project
.pydevproject
.idea
5 changes: 5 additions & 0 deletions README.markdown
Expand Up @@ -22,6 +22,11 @@ token_hex = 'b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b87'
payload = Payload(alert="Hello World!", sound="default", badge=1)
apns.gateway_server.send_notification(token_hex, payload)

# Send an iOS 10 compatible notification
token_hex = 'b5bb9d8014a0f9b1d61e21e796d78dccdf1352f23cd32812f4850b87'
payload = Payload(alert="Hello World!", sound="default", badge=1, mutable_content=True)
apns.gateway_server.send_notification(token_hex, payload)

# Send multiple notifications in a single transmission
frame = Frame()
identifier = 1
Expand Down
7 changes: 6 additions & 1 deletion apns.py
Expand Up @@ -298,14 +298,16 @@ def __init__(self, payload_size):

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

def dict(self):
Expand All @@ -328,6 +330,9 @@ def dict(self):
if self.content_available:
d.update({'content-available': 1})

if self.mutable_content:
d.update({'mutable-content': 1})

d = { 'aps': d }
d.update(self.custom)
return d
Expand Down

0 comments on commit cee961b

Please sign in to comment.