Skip to main content

APNS Certificate/ PEM file

APNS Certificate/ PEM file

In order to send push notifications to your app, an APNS certificate has to be created for your app and the same has to be converted to .pem format and uploaded to our dashboard. Follow the steps below to create APNS certificate for your app :

Generating the Certificate Signing Request (CSR)

Open Keychain Access on your Mac (it is in Applications/Utilities) and choose the menu option Request a Certificate from a Certificate Authority.
You should now see the following window:
Enter your email address here. Enter your app name for Common Name. This allows us to easily find the private key later. Check Saved to disk and click Continue. Save the file as “Yourappname.certSigningRequest”.
Go to the Keys section of Keychain Access, you will see that a new private key has appeared in your keychain. Right click it and choose Export. Save the private key as yourappkey.p12 and enter a passphrase.

Creating an App ID and SSL Certificate

Login to the iOS Dev Center and “Select the Certificates, Identifiers and Profiles” from the left panel. Select Certificates in the iOS Apps section. Go to App IDs in the Identifiers and click the + button.
Fill the following details in the window presented: App ID. Description: yourappname In the App Services. Make sure you check the Push Notifications Checkbox. Explicit App ID: your app bundle id (in the format com.example.exampleapp).
Press the Continue button. You will be asked to verify the details of the app id, if everything seems fine, click Submit. You have successfully registered a new App ID.
After you have made the App ID, it shows up in the App IDs list. Select the yourappname app ID from the list. This will open up a window as shown below:
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 Edit button to configure these settings.
Scroll down to the Push Notifications section and select the Create Certificate button in the Production SSL Certificate section.
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 click Continue. In the next step you upload the CSR. Choose the CSR file that you generated earlier and click Generate.
In the Your certificate is ready window, Download the certificate, it is named “aps_prod.cer”.

Creating a PEM file

So now you have 2 files: The private key as a p12 file - yourappkey.p12 and the SSL certificate - aps_prod.cer
Convert the .cer file into a .pem file:
$ openssl x509 -in aps_prod.cer -inform der -out yourappnamecert.pem
Convert the private key’s .p12 file into a .pem file:
$ openssl pkcs12 -nocerts -out yourappnamekey.pem -in yourappkey.p12
Enter Import Password:
MAC verified OK
Enter PEM pass phrase:
Verifying - Enter PEM pass phrase:
Now verify that your PEM file is correct.
Test it using the following command:
openssl s_client -connect gateway.sandbox.push.apple.com:2195 -cert “Certificate_name”.pem -key “Certificate_key”.pem 
Replace the "Certificate_name" and "Certificate_key" with your certificate name and key respectively. Remove the quotes.
Use the password which you used for converting the p12 to pem.
If you get the status CONNECTED(00000003) OR CONNECTED(00000006) , and the master key in the end, then the PEM is fine.
Else, please ensure that the two files you have are correct, or contact the iostutorialpoint team for help with the same.
Once the verification is done, combine the certificate and key into a single .pem file:
cat yourappnamecert.pem yourappnamekey.pem > finalkeytobeuploaded.pem

Uploading PEM file to MoEngage Dashboard

Open the settings page in the MoEngage Dashboard, go to Settings > Push > Mobile Push > iOS. Follow the steps below for uploading the .pem file:
  1. Upload the pem file which contains both certificate and key information.
  2. Enter the password for the key.

Comments

Popular Posts

What are the Alternatives of device UDID in iOS? - iOS7 / iOS 6 / iOS 5 – Get Device Unique Identifier UDID

Get Device Unique Identifier UDID Following code will help you to get the unique-device-identifier known as UDID. No matter what iOS user is using, you can get the UDID of the current iOS device by following code. - ( NSString *)UDID { NSString *uuidString = nil ; // get os version NSUInteger currentOSVersion = [[[[[UIDevice currentDevice ] systemVersion ] componentsSeparatedByString: @" . " ] objectAtIndex: 0 ] integerValue ]; if (currentOSVersion <= 5 ) { if ([[ NSUserDefaults standardUserDefaults ] valueForKey: @" udid " ]) { uuidString = [[ NSUserDefaults standardDefaults ] valueForKey: @" udid " ]; } else { CFUUIDRef uuidRef = CFUUIDCreate ( kCFAllocatorDefault ); uuidString = ( NSString *) CFBridgingRelease ( CFUUIDCreateString ( NULL ,uuidRef)); CFRelease (uuidRef); [[ NSUserDefaults standardUserDefaults ] setObject: uuidString ForKey: @" udid " ]; [[ NSUserDefaults standardUserDefaults ] synchro...

An introduction to Size Classes for Xcode 8

Introduction to Size Classes for Xcode In iOS 8, Apple introduced  size classes , a way to describe any device in any orientation. Size classes rely heavily on auto layout. Until iOS 8, you could escape auto layout. IN iOS8, Apple changed several UIKit classes to depend on size classes. Modal views, popovers, split views, and image assets directly use size classes to determine how to display an image. Identical code to present a popover on an iPad  causes a iPhone to present a modal view. Different Size Classes There are two sizes for size classes:  compact , and  regular . Sometime you’ll hear about any.  Any  is the generic size that works with anything. The default Xcode layout, is  width:any height:any . This layout is for all cases. The Horizontal and vertical dimensions are called  traits , and can be accessed in code from an instance of  UITraitCollection . The  compact  size descr...

How To Transfer your app to another iOS Developer Account - iTunes

Transfer your app to another iOS Developer Account Apple states all apps must be submitted by the provider of the app’s content using their own, unique Apple Developer Account, this also applies to existing, already published apps. If you currently have one or more apps published on your developer account, the Apple review will now include this check when you submit a store update. In order to avoid any disruptions in the availability of your app in the iOS store, please make sure all your apps are published on a matching developer account. If the app and the developer account do not match, Apple will potentially reject the update. Your older version of the app will remain available. Fortunately it is possible, and relatively simple, to transfer the ownership of an app to another developer without removing the app from the App Store. When an app is transferred it will keep its reviews and ratings and users will still have access to future updates. You can transfer multi...