Ionic - push notifications - 'pushNotification' of undefined


#1

Hi

I would like to create Ionic app with notifications.
I installed PushPlugin and this is my controller:

    .controller('MainCtrl', function($scope,$ionicPlatform,$cordovaPush) {
      $ionicPlatform.ready(function () {
        var androidConfig = {
          "senderID": "ID"
        };
    
          $cordovaPush.register(androidConfig).then(function(result) {
            // Success
            console.log(result);
          }, function(err) {
            // Error
          });
      })
    });

After run by ionic serve I’ve got error:

ng-cordova.js:6180 Uncaught TypeError: Cannot read property
’pushNotification’ of undefined

I found some solutions, so I’ve modified my code:

index.html (only head tag):

    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
        <title></title>
        <link href="css/ionic.app.css" rel="stylesheet">
    
        <script src="lib/ionic/js/ionic.bundle.js"></script>
    
        <script src="lib/ngCordova/dist/ng-cordova.js"></script>
    
        <script src="cordova.js"></script>
        <!-- copy from plugin www folder -->
        <script src="js/libs/PushNotification.js"></script>
    
        <script src="js/app.js"></script>
        <script src="js/controllers.js"></script>
    </head>

and my controller:

    .controller('MainCtrl', function($scope,$ionicPlatform,$cordovaPush) {
      $ionicPlatform.ready(function () {
        var androidConfig = {
          "senderID": "ID"
        };
    
          if (window.plugins && window.plugins.pushNotification){
              console.log("plugins"); //it displays
              $cordovaPush.register(androidConfig).then(function(result) {
                // Success
                console.log(result);
              }, function(err) {
                // Error
              });
            }
      })
    });

Now, I’ve got:

Uncaught ReferenceError: cordova is not defined

I’m confused, how to run it.

Plugin list:

com.phonegap.plugins.PushPlugin 2.5.0 "PushPlugin"
cordova-plugin-console 1.0.3 "Console"
cordova-plugin-device 1.1.2 "Device"
cordova-plugin-splashscreen 3.2.2 "Splashscreen"
cordova-plugin-statusbar 2.1.3 "StatusBar"
cordova-plugin-whitelist 1.2.2 "Whitelist"
ionic-plugin-keyboard 2.2.0 "Keyboard"

#2

Hi sir,

I have used phonegap-plugin-push this plugin and i have register device and successfully sent notification from server.
But I dont get notification plz help for this query.


#3

can u please send your solution to my email ,because i am not getting any register devices and notifications also.please help me