Phonegap Build Push Notification插件问题

时间:2013-10-14 20:56:48

标签: cordova push-notification phonegap-plugins phonegap-build

我有一个非常奇怪的问题,现在让我疯了一天。我有一个Phonegap Build 3.0应用程序,我正在尝试集成Push plugin。问题在于,即使我遵循文档和许多很多例子,这些东西也不会起作用。我无法触发成功或错误回调,并且try / catch报告没有问题。

目:

<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包含:

<access origin="*"/>

<gap:platform name="android" />
<gap:platform name="ios" />

<gap:plugin name="com.phonegap.plugins.pushplugin" />

非常感谢任何帮助。

1 个答案:

答案 0 :(得分:1)

问题已解决。事实证明,myPushNotification.register(gcmRegistrationSuccessHandler, gcmRegistrationErrorHandler, {"senderID":"I have my Sender ID here","ecb":"onNotificationGCM"});中的“gcmRegistrationSuccessHandler”回调永远不会被调用。只调用“onNotificationGCM”,您必须根据该操作采取所有操作。当然希望有记录......