How can I implement Push Notifications on my iOS app?

In order to send push notifications to your iOS apps, you need to generate .p12 certificates to use in the app.To create your certificates, you can follow this guide:

As long as your iOS device detects push, you don’t need apple developer account. There are 4 main steps to use Push.

  1. App ID and SSL certification: This certificate will allow the Parse server to send push notifications to the application identified by the App ID.

  2. Provisioning profile for this app ID: It authenticates your device to run the app you are developing. Whether you have created a new App ID or modified an existing one, you will need to regenerate your provisioning profile and install it.

  3. Configure Parse app using SSL certificate generated: To use Push Notifications with Parse, you will need to enable this feature in your Parse app and upload the Push SSL certificate you created above

Let’s go through each of them in detail.

  • App ID and SSL certification

Before getting SSL certificate you need to sign a certificate signing request file. To do this, open your Keychain application. Go to keychain access and request a certificate from the certificate authority. Fill the required information and download the .cert signing request file.

Now, log in to the apple developer portal. Go to iOS provisioning portal. Select App IDs from the menu.

If you have already configured an App ID for your app, double check that it was set up as an Explicit App ID. Wildcard App IDs cannot support push notifications and they are easy to identify: the last character in the bundle identifier is an asterisk (*). Wildcard App IDs cannot be converted to Explicit App IDs, but setting up a new App ID for your app is quite straightforward.

Select the new app ID button. Fill the form with all the details. Click on submit.

You will find your app ID in the list and there is an option to configure it. You will find the SSL certificate that you are looking for.

If you are still developing your app, you can pick Development Push SSL Certificate, else if you are ready to launch go for Production Push SSL Certificate.

In the next step select the .cert file that we created earlier. Generate and download the SSL certificate.

Double click on the SSL certificate to install it. You will find this in your certificates list. You can right click on the Apple SSL certificate and save it as a P12 file.

Do not enter an export password when prompted! Leave both fields blank and click OK.

  • Provisioning profile for this app ID

Navigate back to the Apple development portal to the provisioning profile. You can use an existing App ID and existing provisioning profile. But you need to regenerate and reinstall it. If you want to create a new one, select new profile.

Fill in all the information and select your SSL certificate, app ID and the device you will be testing with. Submit to create the new profile.

Download the profile you created and double click on it to install it on your computer. The utility of your iPhone will prompt to add the new profile. Do that and close that app.

  • Configure Parse app using SSL certificate generated

To begin using Push feature you need to inform back{4}app about it. To do that, go to your app on the dashboard. Go to settings tab. Under this you have iOS Push notifications settings. Select your .p12 certificate that you generated. Click on development or production as appropriate. If you want the app itself to initiate the push click on yes under Client push enabled.

Start by configuring your Xcode application’s project settings. We’ll need to make sure that both the App ID and the provisioning profile are configured correctly.

Select your project in the Project navigator, then select your application target in the main Editor window. Make sure “General” is selected at the top.

Modify the Bundle Identifier field under Identity to match your App ID’s Bundle Identifier (ex. com.example.MyParsePushApp). Xcode may warn you at this point if you have not configured your provisioning profile correctly.

Xcode configuration

Click on “Capabilities” and turn on Push Notifications. Again, Xcode will let you know if there are any issues that require your attention. Click on “Build Settings” and find the “Code Signing Identity” field. This field should be set to “iOS Developer” if you’re testing against development, or “iOS Distribution” if you’re testing in production or building your app for the App Store.

Make sure the provisioning certificate is configured correctly in your app. Then this is how you can configure Push notification.

Here are the changes you need to make in app delegate in order to receive push notifications.

Call the method registerForRemoteNotifications to register the current device for push.

If the registration is successful, the callback method application:didRegisterForRemoteNotificationsWithDeviceToken should be implemented. This method is called after the device is successfully registered.

To notify about the Push, call the method storeDeviceToken on PFPush object.

Next subscribe the user to the broadcast channel using the method subscribeToChannelInBackground with an empty string.

If the device fails to register you can call the method didFailToRegisterForRemoteNotificationWithError to handlethe error. Print an appropriate error message. This is displayed if the application is running in the foreground.

But if it is running in the background we can handle it using application didReceiveRemoteNotification. This helps to display modal notification content.

After this build your application. Plug in your iOS device. Run it and close the display.

In your app go to Push notifications tab. Send a sample message on the broadcast channel. Check this notification on your iOS phone.

We are working on making it possible to upload your certificates through the web dashboard. Meanwhile, you can contact us through the live chat or email and we will setup it for you.