Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
  • Setup Push Notification with PhoneGap and Android

    • 0
    • 1
    • 1
    • 1
    • 0
    • 0
    • 0
    • 0
    • 517
    Comment on it

    Hello All,
    If you want to setup a push notifications with PhoneGap and Android, here below I am providing the guidelines, you only have to follow the steps one by one-

    So first of all you have to install push plugin for PhoneGap.

    The plugin can be installed via the Cordova command line interface give below-:

     $ cordova plugin add

    You also need the PhoneGap device plugin:

      $ cordova plugin add org.apache.cordova.device

    Now copy pushNotification.js into www folder and Include this file in your apps index.html -file:
    for example : <script src = "pushNotification.js></script>

    Now you just need to Setup your app within Google Developer Console:
    So first log-in Google Developer Console. This Blog does not go into depth about creating accounts on Google Cloud Messaging, below link will provide you information about how to generate Project ID, Project Number and API Key-
    Now we just need to add some JavaScript to allow our app to register the users device and to receive push notifications on it:

    var pushNotification;
    document.addEventListener( "deviceready", onDeviceReady, false );
    function onDeviceReady() {
         pushNotification = window.plugins.pushNotification;
            if ( window.device.platform == 'android' || device.platform == 'Android' ){
                    // Register for Android:
                         pushErrorHandler, {
                          "senderID":"044354353455", // Project number from Google Developer Console
          // Success handler for when connected to push server            
          function pushSuccessHandler(result) {
           // Error handler for when not connected to push server
           function pushErrorHandler(error) {
        // Notification from Android GCM
    var onNotificationGCM = function(e) {
        // Check which event:
            case 'registered' :
                        console.log('android reg id: ' + e.regid);

 0 Comment(s)

Sign In

Sign up using

Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: