-
Notifications
You must be signed in to change notification settings - Fork 21
/
apns-feedback
executable file
·41 lines (26 loc) · 983 Bytes
/
apns-feedback
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/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()