Push notification is describes a style of Internet-based communication where the request for a given transaction is initiated by the publisher or central server. It is contrasted with pull, where the request for the transmission of information is initiated by the receiver or client (Wikipedia).
There are two types of push notification service that mostly popular among the others are android and iOS. I’m not sure about blackberry and windows mobile because currently doing only for iOS and android platform.
Push notification for iOS called APNs stands for Apple Push Notification Service. For android called GCM stands for Google Cloud Messaging. You can find more details about both of these services at their official site.
APNs
GCM
APNs - https://developer.apple.com/library/ios/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html
GCM - http://developer.android.com/google/gcm/index.html
Last month I already attend worklight training located at Plaza IBM, One Utama organised by IBM. I already post an article about this training details here.
http://blog.revivalx.com/2014/02/18/ibm-worklight-training-day-2/
Besides that, you can find more details about APNs and GCM from third party links.
APNs
http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1
http://devgirl.org/2012/10/19/tutorial-apple-push-notifications-with-phonegap-part-1/
GCM
http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/
Ok, enough chit chat. Now, I want to share with you how to do push notification phonegap plugin for android platform. First, you need to create cordova project. Make sure you have eclipse Juno and Xcode (for mac users).
cordova create project
Open up your config.xml in your project then edit project id and name.
Go to your project directory then add these two platforms into your cordova project, iOS and android.
Run this command in your terminal.
android
iOS
Create a new project in eclipse.
eclipse new project 1
eclipse new project 2
eclipse new project 3
Make sure your project hierarchy look like this one.
Download this phonegap plugin and install into your cordova project.
https://github.com/phonegap-build/PushPlugin
https://github.com/apache/cordova-plugin-console
Run this command to install this plugin into your project.
cordova plugin
To make your push notifications works, you need to register your app first in google cloud (android) and apple developer (iOS). For android part, you need project id for push notification recognise your device. Otherwise, it won’t work. You can refer this tutorial how to register your app.
iOS: http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1
Android: http://www.androidhive.info/2012/10/android-push-notifications-using-google-cloud-messaging-gcm-php-and-mysql/
Below are websites that you need to register your app for push notification.
Google Cloud: https://cloud.google.com
Apple Developer: https://developer.apple.com/
After you finish registered your app, go back to your eclipse and insert this script into your index.html .
https://github.com/phonegap-build/PushPlugin/blob/master/www/PushNotification.js
index.html
Then build your project. Run these command in your terminal.
cordova build ios
cordova build android
I will continue on the second part about how to test your push notification for android and ios. Don’t hesitate to contact me if you had problem about this.