From d3a841265e061fd677f64b2f11a32be4beba05eb Mon Sep 17 00:00:00 2001 From: Sergey Petrov Date: Sun, 8 Jan 2017 23:13:02 +0300 Subject: [PATCH] Add support for Safari Push Notifications --- apns2/payload.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/apns2/payload.py b/apns2/payload.py index 6c92105..1d2e029 100644 --- a/apns2/payload.py +++ b/apns2/payload.py @@ -4,7 +4,7 @@ MAX_PAYLOAD_SIZE = 4096 class PayloadAlert(object): def __init__(self, title=None, title_localized_key=None, title_localized_args=None, body=None, body_localized_key=None, body_localized_args=None, - action_localized_key=None, + action_localized_key=None, action=None, launch_image=None): self.title = title self.title_localized_key = title_localized_key @@ -13,6 +13,7 @@ class PayloadAlert(object): self.body_localized_key = body_localized_key self.body_localized_args = body_localized_args self.action_localized_key = action_localized_key + self.action = action self.launch_image = launch_image def dict(self): @@ -34,6 +35,8 @@ class PayloadAlert(object): if self.action_localized_key: result['action-loc-key'] = self.action_localized_key + if self.action: + result['action'] = self.action if self.launch_image: result['launch-image'] = self.launch_image @@ -44,12 +47,13 @@ class PayloadAlert(object): class Payload(object): def __init__(self, alert=None, badge=None, sound=None, content_available=False, mutable_content=False, - category=None, custom=None): + category=None, url_args=None, custom=None): self.alert = alert self.badge = badge self.sound = sound self.content_available = content_available self.category = category + self.url_args = url_args self.custom = custom self.mutable_content = mutable_content @@ -72,6 +76,8 @@ class Payload(object): result['aps']['mutable-content'] = 1 if self.category is not None: result['aps']['category'] = self.category + if self.url_args is not None: + result['aps']['url-args'] = self.url_args if self.custom is not None: result.update(self.custom)