I have been looking everywhere for example code on how to do this from a python written server over GAE - but with no luck.
Can someone please help me with the function to do this? (It should be pretty straight forward I believe).
I have been looking everywhere for example code on how to do this from a python written server over GAE - but with no luck.
Can someone please help me with the function to do this? (It should be pretty straight forward I believe).
I use this library, and it works well in my app.
https://github.com/simonwhitaker/PyAPNs
enable ssl in app.yaml
libraries:
- name: ssl
version: latest
code is like below, token_hex == a push notification token sent from a device. And you have to some variables.
from apns import APNs, Payload
apns = APNs(use_sandbox=use_sandbox,
cert_file=path/to/cert.pem',
key_file=path/to/key-noenc.pem')
payload = Payload(alert='hello', sound="default", badge=1,custom={})
apns.gateway_server.send_notification(token_hex, payload)
for (token_hex, fail_time) in apns.feedback_server.items():
logging.info(token_hex)
logging.info(fail_time)
Maybe you may consider this forked version of PyAPNS that has enhanced message support.
https://github.com/jimhorng/PyAPNs
which means it will catch error response for failure messages and resent the message which are discarded by APNS while sending between failure messages and receiving error response.
Solution:
Result: