title: implementing push notification in ionic app
body: <p>I am trying to implement push notification in ionic app for Android.
  I have followed step by step guide from <a href="http://docs.ionic.io/v1.0/docs/push-from-scratch" rel="nofollow">http://docs.ionic.io/v1.0/docs/push-from-scratch</a>.
  When I am running my app on android phone, then the registered users are listed in apps.ionic.io. So user registration is working fine.
  But device registration is not working.
  It is giving error <strong>Cannot read property 'pushNotification' of undefined</strong></p>
  
  <p>This is my code at the top of app.js</p>
  
  <pre><code>angular.module('starter', ['ionic','ngCordova',
      'ionic.service.core',
      'ionic.service.push',
      'starter.controllers',
      'starter.services'])
  
      .config(['$ionicAppProvider', function($ionicAppProvider) {
          // Identify app
          $ionicAppProvider.identify({
              // The App ID (from apps.ionic.io) for the server
              app_id: '',
              // The public API key all services will use for this app
              api_key: '',
              // Set the app to use development pushes
             // dev_push: true
              gcm_id: ''
          });
      }])
  </code></pre>
  
  <p>Here is the code in of my controller</p>
  
  <pre><code> .controller('DashboardCtrl', function($scope,$localstorage, WildfireService, CommonUtilityService,PushNotificationService,$ionicPopup, $ionicLoading) {      
        PushNotificationService.identifyUser();
        PushNotificationService.pushRegister();
  
      })
  </code></pre>
  
  <p>Here is my services.js</p>
  
  <pre><code> .service('PushNotificationService', function($q, $ionicUser, $ionicPush) {
          var PushNotificationService = this;
          PushNotificationService.identifyUser  = function(){
              var user = $ionicUser.get();
              if(!user.user_id) {
                  // Set your user_id here, or generate a random one.
                  user.user_id = $ionicUser.generateGUID();
              };
  
              // Add some metadata to your user object.
              angular.extend(user, {
                  name: 'Technews',
                  bio: 'Hardcoded for now'
              });
  
              // Identify your user with the Ionic User Service
              $ionicUser.identify(user).then(function(){
                  //alert('Identified user ' + user.name + '\n ID ' + user.user_id);
                  return true;
              });
          },
  
          PushNotificationService.pushRegister = function(){
              // Register with the Ionic Push service.  All parameters are optional.
              $ionicPush.register({
                  canShowAlert: true, //Can pushes show an alert on your screen?
                  canSetBadge: true, //Can pushes update app icon badges?
                  canPlaySound: true, //Can notifications play a sound?
                  canRunActionsOnWake: true, //Can run actions outside the app,
                  onNotification: function(notification) {
                      // Handle new push notifications here
                      // console.log(notification);
                      alert(notification);
                      return true;
                  }
              });
          }
      })
  </code></pre>
  
  <p>Can any one tell me where is the error or what I am missing?</p>
  
  <p>I have added these in index.html</p>
  
  <pre><code>&lt;script src="lib/ionic/js/ionic.bundle.js"&gt;&lt;/script&gt;
      &lt;script src="lib/ngCordova/dist/ng-cordova.js"&gt;&lt;/script&gt;
      &lt;script src="lib/ionic-service-core/ionic-core.js"&gt;&lt;/script&gt;
      &lt;script src="lib/ionic-service-push/ionic-push.js"&gt;&lt;/script&gt;
  </code></pre>