Skip to content

Instantly share code, notes, and snippets.

@tudormunteanu
Created January 15, 2015 10:30
Show Gist options
  • Save tudormunteanu/deee6f2be0df8d554585 to your computer and use it in GitHub Desktop.
Save tudormunteanu/deee6f2be0df8d554585 to your computer and use it in GitHub Desktop.
Safari Push Payload
from djacobs_apns.apns import APNs, Payload
# the payload for Safari
class PayloadSafari(Payload):
def __init__(self, alert=None, url_args=[]):
super(Payload, self).__init__()
self.alert = alert
self.url_args = url_args
self._check_size()
def dict(self):
d = {"alert": self.alert, "url-args": self.url_args}
d = {'aps': d}
#print d
return d
# sending the push notification
alert_dict = {"title": push_message.title, "body": push_message.body, "action": "View"}
payload = PayloadSafari(alert = alert_dict, url_args = ['anything-for-the-url'])
apns = APNs(use_sandbox=False, cert_file=cert_path, key_file=key_path)
apns.gateway_server.send_notification(token, payload)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment