1

I successfully managed to send push notifications from command line using the Send a Push Notification Using a Certificate example, which uses both the certificate.cer and the key.key to establish the connection with the APNs server.

I wish to run a python script to automate push notifications and wanted to use PyAPNs2 module for that. However, I cannot figure out how to provide the certificate the the key when creating the APNsClient() instance. Using either file as provided in the README.md example does not work:

client = APNsClient('key.pem', use_sandbox=False, use_alternative_port=False)

I also looked into merging the two files into one, but the approach described here throws an error during merging: "unable to load certificates". I am not sure that's the path I should take.

Any suggestions? Alternatively, can someone suggest a good python based API for sending push notifications to the APNs?

Nazar
  • 820
  • 5
  • 13
  • 36
  • Things to check: (1) Does your script have read permissions to key.pem (2) is key.pem in a format that PyAPNs2 is expecting – Alex Urcioli Jun 29 '22 at 01:32
  • @AlexUrcioli That's strange. Since this package was developed specifically for APNs interface, why would it take an input file that does not conform to the original format provided by the Apple Development Program? – Nazar Jun 29 '22 at 23:19

0 Answers0