Skip to content

Instantly share code, notes, and snippets.

@leepa leepa/gist:145257
Created Jul 11, 2009

Embed
What would you like to do?
import struct
from socket import socket
import ssl
import binascii
payload = '{"aps":{"alert":"Hello World","sound":"chime"}}'
fmt = "!cH32sH%ds" % len(payload)
command = '\x00'
token = '<<removed>>'
msg = struct.pack(fmt, command, 32, binascii.unhexlify(token), len(payload), payload)
s = socket()
c = ssl.wrap_socket(s,
ssl_version=ssl.PROTOCOL_SSLv3,
certfile='ck.pem')
c.connect(('gateway.sandbox.push.apple.com', 2195))
c.write(msg)
c.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.