我有一个非常奇怪的问题让我发疯了一天。我有一个 Phonegap Build 3.0 应用程序并正在尝试集成Push 插件。问题是,即使我遵循文档和许多许多示例,该死的东西也行不通。我无法让它触发成功或错误回调,并且 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" />
任何帮助将不胜感激。