and for hypercrypt and other devs here's some early push code written in python which I love so very much more than obj-c
Code:
#!/usr/bin/env python2.6
import socket, ssl, json, struct, urllib, time, sys
from xml.dom.minidom import parse, parseString
# Needs python 2.6 - for 2.5 replace ssl and json (with simplejson)
# Export your "Apple Development Push Services" certificate from your Keychain (important: select it from the "My Certificates" category in the sidebar). Export the certificate as a "Personal Information Exchange (.p12) file. You shouldn't give the exported file a password (well you could but YMMV).
# Convert the .p12 file you just exported into a pem file:
# openssl pkcs12 -in certificates.p12 -out certfile.pem -nodes -clcerts
# Replace the device token with YOUR applications device token.
# For testing don't forget to quit the app (you wont see the push notification dialogs while the app is running).
# Tested on iPod 1st Generation with 3.0b2 - yes it all works.
for arg in sys.argv:
if arg.startswith('--'):
Message = arg[2:]
print 'Sending: ' + Message
url = 'whereever your xml is'
filehandle = urllib.urlopen(url, data)
time.sleep(5)
xml = filehandle.read()
xmldoc = parseString(xml)
nodeArray = xmldoc.getElementsByTagName('deviceToken')
tokens = []
for node in nodeArray:
try:
deviceToken = node.firstChild.toxml()
tokens.append(deviceToken)
except:
continue
for deviceToken in tokens:
thePayLoad = {
'aps': {
'alert':Message,
'sound':'default',
'badge':1,
},
}
theCertfile = 'cert.pem'
theHost = ('gateway.push.apple.com', 2195)
data = json.dumps(thePayLoad)
deviceToken = deviceToken.replace(' ','').decode('hex')
theFormat = '!BH32sH%ds' % len(data)
theNotification = struct.pack(theFormat, 0, 32, deviceToken, len(data), data)
ssl_sock = ssl.wrap_socket(socket.socket(socket.AF_INET, socket.SOCK_STREAM), certfile=theCertfile)
ssl_sock.connect(theHost)
ssl_sock.write(theNotification)
ssl_sock.close()
print 'Done Transmitting'
and use this openssl to turn a p12 into a pem that doesn't require a password
openssl pkcs12 -in certificates.p12 -out certfile.pem -nodes -clcerts