Chase Roberts
Chase Roberts

Reputation: 9376

Sending iOS push notifications with python and PyAPNS

I am trying to figure out how to send push notifications with my python/django app. I found some code online which works when I run it from the terminal but it prompts me to enter in the PEM passphrase manually and I don't know how to set it up so that it just works on it's own.

from apns import APNs, Payload

apns = APNs(use_sandbox=True, cert_file='/Users/user/Desktop/Lunch-BoxCert.pem',key_file='/Users/user/Desktop/Lunch-BoxKey.pem')
token = '923...8b4'
# Send a notification
payload = Payload(alert="Hello World!", sound="default", badge=1)
apns.gateway_server.send_notification(token, payload)

When I run it by calling python manage.py runserver it blocks until I type the passphrase into the terminal. Anyway know how to solve this?

Upvotes: 2

Views: 5560

Answers (1)

Chase Roberts
Chase Roberts

Reputation: 9376

I ended up just removing the passkeys.

openssl rsa -in apns-dev-key.pem -out apns-dev-key-noenc.pem

I kind of followed this tutorial here:

https://blog.serverdensity.com/how-to-build-an-apple-push-notification-provider-server-tutorial/

Upvotes: 1

Related Questions