我有一個非常奇怪的問題,現在已經讓我瘋狂了一天。我有一個Phonegap Build 3.0應用程序,並試圖集成Push plugin。問題是,即使我遵循文檔和很多很多的例子,dang的東西就不會工作。我無法讓它解決成功或錯誤回調,try/catch報告沒有問題。Phonegap Build推送通知插件問題
頭:
<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" />
任何幫助將不勝感激。
更新:我在Phonegap Build的調試模式下運行了這個,並試圖直接調用myPushNotification.register(gcmRegistrationSuccessHandler,gcmRegistrationErrorHandler,{「senderID」:「我在這裏有我的發件人ID」,「 ecb「:」onNotificationGCM「});'並且日誌顯示它返回爲未定義的地方,因爲調用'myPushNotification = window.plugins.pushNotification;'返回它應該的對象。 – Dom