How to create a PEM file for iOS push notifications -part 1

While building the mobile app with SimiCart, many customers encounter difficulties in creating a pem file for iOS push notifications . So in this blog, I will guide you how to create a PEM file. As it is quite long, I will divide it into 2 parts, this is part 1 .

Overview

iOS app allows to push notification to all the mobile user. There are three things a push notification can do:

Display a short text message

Play a brief sound

Set a number in a badge on the app’s icon

PEM file is used to setup Apple Push Notification. In this tutorial, you will be guided to generate a PEM file.
Basically, to get a PEM file, you need to generate 3 following files:
(1) Certificate Signing Request (CSR file)
(2) SSL certificate (aps_ distribution.cer)
(3) Private key as a .p12 file

Okay. let’s start now

Step 1: Generating the Certificate Signing Request (CSR)

Whenever you apply for a digital certificate, you need to provide a Certificate Signing Request or CSR for short. When you create the CSR, a new private key is made that is put into your keychain. You then send the CSR to a certificate authority (in this case that is the iOS Developer Portal), which will generate the SSL certificate for you based on the information in the CSR.
Go to Applications/Utilities/Keychain Access on your Mac and choose the menu option Request a Certificate from a Certificate Authority

If you do not have this menu option or it says “Request a Certificate from a Certificate Authority with key”, then download and install the WWDR Intermediate Certificate first. Also make sure no private key is selected in the main Keychain Access window.
You should now see the following window:

(1) User email address: enter your email address here. It can be either same email address used to sign up for the iOS Developer Program or any email address.
(2) Common Name: enter anything you want but it should be something descriptive. For example, your app name. Here I put it as PushChat
(3) Check Saved to disk and click Continue. Save the file as “PushChat.certSigningRequest”.

Step 2: Making the App ID and SSL Certificate

(1) Log into the iOS Dev Center ; select the “Certificates, Identifiers and Profiles” from the right panel.

(2) You will be presented with the following screen. Select Certificates in the iOS Apps section.

(3) Each push app needs its own unique ID because push notifications are sent to a specific application. So please go to App IDs in the sidebar and click the + button.

(4) You will be presented with the following screen

Then fill the following details:

[signinlocker]

• App ID Description: name your ID. In this case, I name it PushChat
• Explicit ID: the identification key of your app. In SimiCart, the identification key is formatted com.simicart.appname
Don’t forget to enable App Services Check the Push Notifications
Then click Continue button. You will be asked to verify the details of the App ID, if everything seems okay click Submit.

In a few moments, you will generate the SSL certificate that your push server uses to make a secure connection to APNS. This certificate is linked with your App ID. Your server can only send push notifications to that particular app, not to any other apps.
After you have made the App ID, it shows up like this in the list:

In this case, I select the PushChat app ID from the list. This will open up an accordion as shown below:

Notice: in the “Push Notification” row, there are two orange lights that say “Configurable” in the Development and Distribution column. This means your App ID can be used with push, but you still need to set this up. Click on the Setting button to configure these settings.

Scroll down to the Push Notifications section. Go to Production SSL Certificate/ Create Certificate.

The “Add iOS Certificate” wizard comes up:

The first thing it asks you is to generate a Certificate Signing Request. You already did that, so just click Continue. In the next step you upload the CSR. Choose the CSR file that you generated earlier and click Generate.

Click Continue when it’s done. Then click Download to get the certificate – it is named “aps_development.cer”

As you can see, you have a valid certificate and Push is now available for development. You can download the certificate again here if necessary. The development certificate is only valid for 3 months.
When you are ready to release your app, repeat this process for the production certificate. The steps are the same.Note: The production certificate remains valid for a year, but you want to renew it before the year is over to ensure there is no downtime for your app.
You don’t have to add the certificate to your Keychain, although you could if you wanted to by double-clicking the downloaded aps_development.cer file.