Create .pem file for iOS push notification – Tutorial

Generate .pem file for push notification - tutorial

Introduction to .pem file:

In this tutorial we will learn how to create or generate .pem file for Apple push notification in iOS.Pem file are placed on the server that connects with Apple Push server in order to send push to our iOS app.

Steps to create .pem file for Push Notification:

Step 1: Login with your developer account on Apple developer website

Step 2: Click on certificates, identifiers and profiles as shown in given below image/screenshot

Dashboard of Apple developer account

Step 3:  Click + icon/button in order to start generating push certificate

Step 4: Select Apple push certificate as per your requirement, we have two types of push certificates

1) Apple push Service SSL (Sandbox) –  used to send push notification during app development phase
2) Apple push Service SSL (Sandbox & production) – used to send push notification when app goes live on app store and also during development or sandbox phase. Once certificate for both environments.

But in this tutorial we will go with  Apple push Service SSL (Sandbox)

Select type of push certificate you want to generate

Step 5:  We selected Apple Push Notification SSL listed under Development tab for this tutorial, After selection press continue button at the bottom of the page.

Selected development push certificate
Step 6: Select  app id for which you want to configure Push Notifications and press continue button

Selected App id for which you want to  add push notifications

Select 7: Generate CSR (certificate Signing Request) as described by Apple. If you already have one press continue and upload it by clicking on Choose file button. Press continue to move to next step.

Step 8: You will see your apple development push service certificate. Download it and press done.

Development push certificate created successfully

Step 9: Locate the downloaded certificate in the finder and double click in order to install it in your mac machine. It will open another application called “Keychain Access”.Now go to “Keychain” on you mac system, look for the certificate you have just installed. If you are unsure which certificate is the correct , it should start with “Apple Production IOS Push Services”and  followed by app’s bundleID.

Step 10: Expand the certificate, you should see the private key with either your name or your company name. Select both items by using the “Select” key on your keyboard, right click (or cmd-click if you use a single button mouse), choose “Export 2 items”. It will save as .p12 file.

Export 2 item from keychain access
 Step 11: Save them with name “pushcert”. System will prompt you to secure the exported item with password, enter password (if you don’t want to enter any password then leave it blank). In next step system will ask you to enter your system password in order to complete export.

Step 12: Open terminal and locate to place where you save .p12 files. (in our case its Desktop). Type below command in terminal

cd Desktop

openssl pkcs12 -in pushcert.p12 -out pushcert.pem -nodes -clcerts


Where to go form here:

we are done with this tutorial, as we successfully generated .pem file.You can upload this .pem to your server in order to receive Apple push notification on your devices. Hope, you learned this very easy process of creating  .pem file for Apple push notification. If you have any question please feel free to comment. Happy coding 🙂

1 thought on “Create .pem file for iOS push notification – Tutorial”

  1. Pingback: How to enable Push Notification service for iOS app in Apple Developer account - iOSTutorialJunction

Comments are closed.