Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
executable file 42 lines (26 sloc) 983 Bytes
#!/usr/bin/env python
from apns import APNs
import optparse
from tornado import ioloop
parser = optparse.OptionParser()
parser.add_option("-c", "--certificate-file",
dest="certificate_file",
help="Path to .pem certificate file")
parser.add_option("-k", "--key-file",
dest="key_file",
help="Path to .pem key file")
options, args = parser.parse_args()
if options.certificate_file is None:
parser.error('Must provide --certificate-file')
if options.key_file is None:
parser.error('Must provide --key-file')
apns = APNs(cert_file=options.certificate_file, key_file=options.key_file,
use_sandbox=True)
def success(token_hex, fail_time):
print("Get feedback data token:%s fail_time:%s" %
(token_hex, fail_time))
def receive():
apns.feedback_server.receive_feedback(success)
# receive feedback
apns.feedback_server.connect(receive)
ioloop.IOLoop.instance().start()