Reputation: 2569
I have a very strange issue that has been driving me nuts for a day now. I have a Phonegap Build 3.0 app and am trying to integrate the Push plugin. The problem is that even though I follow the documentation and many, many examples, the dang thing just wont work. I can not get it to fire the success or error callback and the try/catch reports no issues.
Head:
<head>
<script src="assets/js/myScripts.js"></script>
<script src="phonegap.js"></script>
<script type="text/javascript" src="PushNotification.js"></script>
</head>
myScripts.js
var myPushNotification;
document.addEventListener("deviceready", onDeviceReady, false);
function onDeviceReady(){
myPushNotification = window.plugins.pushNotification;
try{
myPushNotification.register(gcmRegistrationSuccessHandler, gcmRegistrationErrorHandler, {"senderID":"I have my Sender ID here","ecb":"onNotificationGCM"});
}
catch(e){
alert(e.message);//******this is never fired******
}
}
function gcmRegistrationSuccessHandler(result){
alert("successfully registered);//******this is never fired******
}
function gcmRegistrationErrorHandler(error){
alert("error registering");//******this is never fired******
}
config.xml contains:
<access origin="*"/>
<gap:platform name="android" />
<gap:platform name="ios" />
<gap:plugin name="com.phonegap.plugins.pushplugin" />
Any help would be greatly appreciated.
Upvotes: 3
Views: 4436
Reputation: 2569
Issue resolved. It turns out that the "gcmRegistrationSuccessHandler" callback in myPushNotification.register(gcmRegistrationSuccessHandler, gcmRegistrationErrorHandler, {"senderID":"I have my Sender ID here","ecb":"onNotificationGCM"});
is never called. Only the "onNotificationGCM" is called and you have to take all actions based on that. Sure wish that was documented...
Upvotes: 1