Enable Apple push notification

Adarsh Kumar
Applozic
Published in
2 min readMar 8, 2016

In continuation with the previous article , this article is intended to explain how iOS remote notification works. Below graphics explain how basics of notification in iOS. We will go through each steps one by one.

Step 1: Register your device with APNS server :

First thing we need to request apple to register your device with apns. For this you need to call below code from your launcher controller.

(void)registerForNotification{

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)

{

[[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];

[[UIApplication sharedApplication] registerForRemoteNotifications];

}else

{

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:

(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];

}

}

Once you call this method from your controller, you will get a callback to your Appdelegate method: didRegisterForRemoteNotificationsWithDeviceToken. You will get device token from apple server in hex format. For a sample code checkout our open source iOS SDK.

Step 2: Send device token to application server:

Once you receive device token after apple registration, you need to send this token to your application server for further use. This device token is the unique identifier for apple to identify your device while sending push notification.

Step 3 : Server will send notification update to device :

For your application server to communicate to apns server, first you need to authenticate yourself to apns. For authentication you need to sign your push request with APNS SSL certificate. Here is the step to step guide how to get APNS SSL certificate.

Once you have apns device token and SSL certificate available on application server, you are good to send push notification to device :).

--

--