ngCordova Push Plugin in Visual Studio 2015

825 views Asked by At

I installed Push Plugin as Custom plugin from the github URL in my Visual Studio project (Tools For Apache Cordova).

However, i am not able to get it working as when i try to reference $cordovaPush in my app, it thows an error:

this is how my angular.run function looks like:

angular.run(function ($ionicPlatform, $cordovaPush) {
    $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();
        }

        var androidConfig = {
            "senderID": "replace_with_sender_id",
        };
        debugger
        $cordovaPush.register(androidConfig).then(function (result) {
            // Success
            debugger
        }, function (err) {
            // Error
            debugger
        })

    });

})

Error in the console: Uncaught Error: [$injector:unpr]

It looks like it does not understand what $cordovaPush is.

1

There are 1 answers

0
Linda Z On

Did you follow the install guide on their site? http://ngcordova.com/docs/install/

If you add ngcordova via bower on the command line (first navigate to the root of the www/ folder), and then reopen your project in VS, the packages should be there (or you can search for them and manually add them to your project.)

Then you can make the code changes (adding script tags and adding ngcordova as a dependency).