Push notification in iOS 10

A simple tutorial to implement push notification in an iOS app.

Sujan Vaidya
Leapfrog

--

Push notification in iOS 10

Push notifications are messages that pops up on a mobile device. These notifications are a nice way to re-engage users with your app once in a while. You find them in messaging apps, social media platforms, weather, and news apps. Each mobile platform has support for push notifications — iOS, Android, Fire OS, Windows and BlackBerry all have their own services.

By following this guide, you’ll be able to implement push notifications in your iOS app and send notifications.

Note: This tutorial is based on the assumption that you are aware of the bundle identifier and already have a valid developer account.

Preparations

Open up Keychain and click on Certificate Assistant to request a new certificate from the certificate authority. Fill up your user email and a name and then select Saved to disk.

Now, login to your developer account from developer website.

Certificates, Identifiers & Profiles.

Select App IDs from Identifiers section. Click the add ‘+’ icon on the top right corner of the screen.

On clicking the add icon, the following screen appears. Fill up the appname and bundle id of your app.

Push Notifications

In the App Services section, look for Push Notifications and click on Continue and click on Register. Then, toggle on to Done.

Find your appname in App IDs section and click on it for editing.

Generate Certificate

In the Push Notification section, on Development SSL Certificate, click on Create Certificate. Click on Continue.

Create Certificate

Choose the file that is previously generated from the Certificate Authority. After you have finished choosing the file click Continue. Now you are ready to Download.

Install the downloaded file which will then appear in Keychain. Select the file and export it from keychain. You will use this file in the backend to communicate with the APNS server for sending the push messages.

downloaded file in Keychain

Save it to your desired location.

Save to desired location

Now open up your project and on the Capabilities section, enable Push Notifications

enable push notifications
enable push notifications

The Whole Code

Here is my Appdelegate.swift file from where you can see the implementation code for registering and handling push notification.

To read similar tech hacks: Subscribe

Leapfrog Technology, Inc. is a technology company that provides software development services for companies and individuals.

Find us on: Facebook, Twitter, and Instagram

Find us on: Facebook, Twitter, and Instagram

--

--