I was using phonegap-plugin-push v1.x.x which was working perfectly in monaca project with onsen-ui v1 and angularJS v1.x.x.
But when I updated the phonegap-plugin-push to v2.0.0 and migrated the google console project to Firebase Console and added the generated google-service.json file to the root folder of the monaca project the PushNotification.init({… function stopped working.
I added the snippets also in the config.xml as documented in the phonegap-plugin-push installation :
<platform name="android">
<resource-file src="google-services.json" target="google-services.json" />
</platform>
I generated custom debugger but it said :
“This following plugins are not included in the debugger phonegap-plugin-push”
So I added the below code to find what went wrong while initialising the plugin :
try
{
var push = PushNotification.init({
android: {
},
browser: {
pushServiceURL: 'http://push.api.phonegap.com/v1/push'
},
ios: {
alert: "true",
badge: "true",
sound: "true"
},
windows: {}
});
push.on('registration', function(data) {
$rootScope.REGISTER_TOKEN = data.registrationId;
alert(Your token is : '+$rootScope.REGISTER_TOKEN);
});
}
catch(e)
{
alert(JSON.stringify(e));
}
But got an alert just saying ERROR and nothing else.
What is wrong in the installation process or code? Please help.