From 5c2f1d0abd1f6689af83cf9368d0b80adc52ee80 Mon Sep 17 00:00:00 2001 From: Luat Vu Dinh Date: Mon, 7 Jan 2019 12:11:06 +0700 Subject: [PATCH] Add thread-id into Payload class --- apns.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apns.py b/apns.py index 33655b1..8c121ec 100644 --- a/apns.py +++ b/apns.py @@ -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 @@ -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}) @@ -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)