How to install phonegap-push-plugin 2.0.0 in monaca with cordova-android version 6.2.0
-
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.
-
@raj-wilson This error is caused by the fact the plugin is failed to include in Monaca Debugger. Which version of the
phonegap-plugin-push
plugin are you using? The latest version (2.2.3
) is currently not working with Monaca. Please use2.1.3
version or lower.
-
I switched over to https://github.com/phonegap/phonegap-plugin-push/tree/v1.x (version 1.11.1) and fallowed the installation as said in https://github.com/phonegap/phonegap-plugin-push/blob/v1.x/docs/INSTALLATION.md, but in vain.
nothing happened, not evenvar push = PushNotification.init({....
orpush.on('registration'...
does not respond anything.I have tested the plugin with both config.xml patterns :
with project id :<plugin name="phonegap-plugin-push" spec="1.6.0"> <param name="SENDER_ID" value="XXXXXXX" /> </plugin>
with fcm id :
<plugin name="phonegap-plugin-push" spec="1.6.0"> <param name="SENDER_ID" value="1:XXXXXXX:android:abcdefghijklmno" /> </plugin>
Both didn’t work.
My project details :
Push Plugin Variable added :
Can you help me to make atleast this version work…
-
@khemry Thanks.
I have found the solution.
For Cordova 6.5.0, phonegap-plugin-push version 1.10.6 and 1.10.5 are compatible none others does.
Other versions > 1.10.6 says gradle 4 depreciated.
Hope, this solution will help someone also.