Created
January 15, 2015 10:30
-
-
Save tudormunteanu/deee6f2be0df8d554585 to your computer and use it in GitHub Desktop.
Safari Push Payload
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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