0
votes

I followed all the instructions to install the PhoneGap Push Plugin at :

https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/INSTALLATION.md

I have also read the example code found here :

https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/EXAMPLES.md

And I tried the plugin with the following sample code :

document.addEventListener("deviceready", notifications(), false);

//NOTIFICATIONS
function notifications(){
    try{
        var push = PushNotification.init({
          android: {}
        });
    }
    catch(err){
        alert("error : " + err);
    }
}

I builded the APK file and I installed it on a real device. When the app is starting, I get the following alert : error : ReferenceError: PushNotification is not defined

I'm working with : Cordova CLI 8.0.0, Cordova Android 7.0.0, PhoneGap Push Plugin 2.1.2

1

1 Answers

-1
votes

I have solved the problem. I found a working sample project at : https://github.com/jcesarmobile/phonegap-plugin-push-sample

The best way to work with this plugin is to write its code in the index.js file just like in the sample project above, instead of another JS file as I did (even if I called the deviceReady event).