Add support for Safari Push Notifications

This commit is contained in:
Sergey Petrov
2017-01-08 23:13:02 +03:00
parent b917868b15
commit d3a841265e
+8 -2
View File
@@ -4,7 +4,7 @@ MAX_PAYLOAD_SIZE = 4096
class PayloadAlert(object): class PayloadAlert(object):
def __init__(self, title=None, title_localized_key=None, title_localized_args=None, def __init__(self, title=None, title_localized_key=None, title_localized_args=None,
body=None, body_localized_key=None, body_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): launch_image=None):
self.title = title self.title = title
self.title_localized_key = title_localized_key self.title_localized_key = title_localized_key
@@ -13,6 +13,7 @@ class PayloadAlert(object):
self.body_localized_key = body_localized_key self.body_localized_key = body_localized_key
self.body_localized_args = body_localized_args self.body_localized_args = body_localized_args
self.action_localized_key = action_localized_key self.action_localized_key = action_localized_key
self.action = action
self.launch_image = launch_image self.launch_image = launch_image
def dict(self): def dict(self):
@@ -34,6 +35,8 @@ class PayloadAlert(object):
if self.action_localized_key: if self.action_localized_key:
result['action-loc-key'] = self.action_localized_key result['action-loc-key'] = self.action_localized_key
if self.action:
result['action'] = self.action
if self.launch_image: if self.launch_image:
result['launch-image'] = self.launch_image result['launch-image'] = self.launch_image
@@ -44,12 +47,13 @@ class PayloadAlert(object):
class Payload(object): class Payload(object):
def __init__(self, alert=None, badge=None, sound=None, def __init__(self, alert=None, badge=None, sound=None,
content_available=False, mutable_content=False, content_available=False, mutable_content=False,
category=None, custom=None): category=None, url_args=None, custom=None):
self.alert = alert self.alert = alert
self.badge = badge self.badge = badge
self.sound = sound self.sound = sound
self.content_available = content_available self.content_available = content_available
self.category = category self.category = category
self.url_args = url_args
self.custom = custom self.custom = custom
self.mutable_content = mutable_content self.mutable_content = mutable_content
@@ -72,6 +76,8 @@ class Payload(object):
result['aps']['mutable-content'] = 1 result['aps']['mutable-content'] = 1
if self.category is not None: if self.category is not None:
result['aps']['category'] = self.category 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: if self.custom is not None:
result.update(self.custom) result.update(self.custom)