django-push-notifications icon indicating copy to clipboard operation
django-push-notifications copied to clipboard

New Apple .p8 apns cert support?

Open IanGleeson opened this issue 6 years ago • 8 comments

Is it possible to add support for apples .p8 apns format? I've tried using it through fcm but received a InvalidApnsCredential error.

They're much easier to work with than .pem

IanGleeson avatar Feb 25 '18 23:02 IanGleeson

This might be something that needs to be done in pyapns2

jleclanche avatar Feb 25 '18 23:02 jleclanche

I'm also having this issue. The current instructions linked refer to a p12 file and Apple doesn't give out p12 files anymore. https://github.com/jazzband/django-push-notifications/blob/master/docs/APNS.rst

I'm really not sure how I'm supposed to continue from this point

jwmann avatar Sep 03 '19 18:09 jwmann

Okay, so I figured out how to get a p12 file and boy let me tell you. There's no way I could've figured this out by myself.

I managed to find this lovely website: https://batch.com/doc/ios/advanced/general.html#_generating-the-p12-certificate

The screenshots are a bit old but the information is still valid.

Here's a quick instruction list for those interested:

  1. Open Keychain Access
  2. Select "Certificates" from the Category Sidebar (not "My Certificates")
  3. Select the "Apple Worldwide Developer Relations Certification Authority" certificate from the list on the right.
  4. Select the Menu "Keychain Access" from the top Menu bar.
  5. From that Menu go into the "Certificate Assistant" Sub Menu.
  6. Select "Request a Certificate from a Certificate Authority"
  7. Select the "Save to Disk" and fill in the Information. Continue until complete.
  8. Go to the Identifiers List page and Select your App (or create one)
  9. Scroll down to Push Notifications section and select "Configure" or "Edit"
  10. Upload your Signing Certificate that you just created.
  11. Continue along the process and download your "cert" file.
  12. Open your new Cert file and add it to your Keychain Access
  13. Select your Cert file from Keychain Access. You should be able to find it under "My Certificates"
  14. Right click the Cert file and Select Export "Apple Push Services: ..."
  15. Give it a password (remember this for later) and Press okay.
  16. You have your p12 file! Now you can follow these instructions

Hopefully this helps someone stuck in the same situation.

jwmann avatar Sep 04 '19 17:09 jwmann

If I would like to add the p8 support to the lib, where is the best way to start?

DataGreed avatar Mar 09 '20 14:03 DataGreed

Okay, so p8 seems to be supported now. The support was silently added in release 2.0.0 (I found it just looking at the sources).

To use p8 you need to set your settings something like this:

PUSH_NOTIFICATIONS_SETTINGS = {
        # "APNS_CERTIFICATE": - this seems to be NO longer needed, comment it out
        "APNS_AUTH_KEY_PATH": os.path.join(BASE_DIR, "your_cert.p8"),
        "APNS_AUTH_KEY_ID": "YOUR_AUTH_KEY",
        "APNS_TEAM_ID": "YOUR_TEAM_ID",
        "APNS_TOPIC": "YOUR_TOPIC", # usually same as device bundle name
        "APNS_USE_SANDBOX": True, #or false
        #"UPDATE_ON_DUPLICATE_REG_ID": True,
}

DataGreed avatar Mar 25 '20 15:03 DataGreed

Would be awesome to add it to readme :)

DataGreed avatar Mar 25 '20 17:03 DataGreed

I've followed these instructions and it connects and immediately closes. Not sure how to debug this.

ianlater avatar Nov 26 '22 20:11 ianlater

@ianlater : FYI mine also connected and immediately closed when using the CLI verification. But it did work just fine.

silviogutierrez avatar Jun 08 '23 17:06 silviogutierrez