CordovaPush not working

I want to use native notifications and I have setup Android and iOS push notifications according to ionic documentation

I have added phone gap push plugin and ngcordova. The ngcordova.js has been imported before cordova.js I am getting $window.plugin not defined error in browser which I believe is expected. But I am getting cannot read property register of undefined error in app which means $cordovaPush is undefined.

.run(function($ionicPlatform, $rootScope, $state, $cordovaPush, $cordovaToast){
  $ionicPlatform.ready(function() {
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
    // for form inputs)
    if(window.cordova && window.cordova.plugins.Keyboard) {
    if(window.StatusBar) {
    function registerForPush(){
      try {
      var config = {};
      //register for push notifications
      if (ionic.Platform.isAndroid()) {
        config = {
          "senderID": "1232"
      }else if (ionic.Platform.isIOS()) {
        config = {
          "badge": "true",
          "sound": "true",
          "alert": "true"
        $cordovaPush.register(config).then(function (result) {
        alert("Register success " + result);
        $cordovaToast.showShortCenter('Registered for push notifications');
        // ** NOTE: Android regid result comes back in the pushNotificationReceived, only iOS returned here
        if (ionic.Platform.isIOS()) {
      }, function (err) {
        console.log("Register error " + err)
      catch(err) {
    // Notification Received
    $rootScope.$on('$cordovaPush:notificationReceived', function (event, notification) {
      if (ionic.Platform.isAndroid()) {
        if (notification.event == "registered") {
          alert("android notification received token - " + notification.regid);
      else if (ionic.Platform.isIOS()) {
       alert("ios notification received");
    document.addEventListener('resume', function () {
    document.addEventListener('pause', function () {
    document.addEventListener('offline', function () {
    document.addEventListener('online', function () {
    window.addEventListener('batterystatus', function (status) {
      $rootScope.$broadcast('batterystatus', status);

});undefined> }


Just to make sure … you are testing on a real device right?

Thats correct. Error on app - cannot read property register of undefined

Now I am getting different error
"Uncaught TypeError: Cannot read property ‘pushNotification’ of undefined", source: file:///android_asset/www/lib/ngCordova/dist/ng-cordova.js (6088)

Is your ng-cordova.js file initiating before your cordova.js file?

Sounds like the push plugin is not loading, maybe try to remove the push plugin and add it back again.

I have tried that but no luck! Yes ng-cordova.js is included before cordoa.js

What If I just use what pushplugin has to offer? This way i can use native notifications. But I am not sure why it is not working with ngCordova :frowning:

As per docs