Follow the steps below to upload a certificate (.pem file) for your app in order to deliver notifications using our APNs1 Push Gateway. Visit Apple APNS docs to learn more about APNs and how it works.
NOTE: This section of the documentation is included for APNs1 legacy use only. While PubNub continues to support legacy certificate configurations, all new users should use APNs2 Push Gateway that uses token based authentication.
Step 1: Request Certificate From Certificate Authority
Keychain Accesson your Mac.
- In top bar of Finder, select
Request a CertificateFrom a Certificate Authority.
- Fill in your email address and name on the following screen. Make sure to leave the
CA email addressblank and select
Saved to disk.
save to desktop
Step 2: Download Push Certificate
First open your Xcode project and navigate to
build informationfor your project. Click on
Toggle the switch for
Now we need to add your
Push Certificateto your Apple Developer Account on the Developer Portal. Go to this address: https://developer.apple.com/account/
On the left, under
Identifiers, click on
App IDs. Then select your app, which should be prepended with something along the lines of
Xcode iOS App ID [bundle identifier]. Open this and click
Editat the bottom
Now scroll down and make sure to
selectthe box for
Push Notificationsand click
The next page brings up a dialog explaining the earlier steps in this tutorial, which we already completed. Click
uploadthe certificate you saved to your desktop in Step 4
Your screen should look like this. Click
Generateto move on
Downloadto get that newly created certificate
Open the newly downloaded certificate in
Keychain Access. It should open in this program automatically if you double click it to open.
Exportthe certificate (click on
My Certificatesin the left side bar of
Keychain Access). Then
right clickon the certificate matching the name of your app, and click on
Save to desktopas
my_cert.p12(must be in
Step 3: Convert Certificate to PEM
Now convert the certificate to
my_cert.pemin preparation for uploading to PubNub with the following command:
openssl pkcs12 -in my_cert.p12 -out my_cert.pem -nodes -clcerts
certwas created correctly by running one of the following commands (depending on whether you are working with a
# For Development Certs openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert my_cert.pem -key my_cert.pem
# For Production Certs openssl s_client -connect gateway.push.apple.com:2195 -cert my_cert.pem -key my_cert.pem
Step 4: Upload PEM to PubNub
certificateto PubNub via https://admin.pubnub.com Select your App on the Apps screen.
Select your keys from the next screen.
In the key options screen, upload
my_cert.pem(make sure to select whether it is
Production). Note it is best practices to use a different set of PubNub keys for