Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add 'thread-id' into Payload class #208

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions apns.py
Original file line number Diff line number Diff line change
Expand Up @@ -306,13 +306,13 @@ 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=None, content_available=False,
mutable_content=False):
def __init__(self, alert=None, badge=None, sound=None, thread_id=None, category=None, custom=None, content_available=False, mutable_content=False):
super(Payload, self).__init__()
self.alert = alert
self.badge = badge
self.sound = sound
self.category = category
self.thread_id = thread_id
self.custom = custom
self.content_available = content_available
self.mutable_content = mutable_content
Expand All @@ -334,6 +334,8 @@ def dict(self):
d['badge'] = int(self.badge)
if self.category:
d['category'] = self.category
if self.thread_id:
d['thread-id'] = self.thread_id

if self.content_available:
d.update({'content-available': 1})
Expand All @@ -355,7 +357,7 @@ def _check_size(self):
raise PayloadTooLargeError(payload_length)

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

Expand Down