Ionic Push Service - $window.plugins is undefined


#1

I’ve got Ionic Push services working, and APNS set up. But when I set the dev_push flag to false I get a $window.plugins is undefined error. I do not get this error when dev_push is set to true - notifications work completely as expected. Any ideas?


#2

I have the same problem. Did you find a solution?


#3

I just found the solution!
Remember to only call $ionicPush.register({… when cordova is done loading - this solved it for me:

$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 && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleLightContent();
}

        $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);
                return true;
            }
        });

    });