嘗試與GSM與PhoneGap的科爾多瓦5.4.1版本的連接,我得到錯誤類沒有發現每次如何解決此問題,請PhoneGap的推送通知類未找到錯誤
我要爲iOS和Android相同的代碼
我的設備上加載事件是這樣的
var pushNotification = window.plugins.pushNotification;
pushNotification.register(app.successHandler, app.errorHandler,{"senderID":"824841663931","ecb":"app.onNotificationGCM"});
// result contains any message sent from the plugin call
successHandler: function(result) {
alert('Callback Success! Result = '+result)
}
和我的JavaScript文件是:
var PushNotification = function() {
};
// Call this to register for push notifications. Content of [options]
depends on whether we are working with APNS (iOS) or GCM (Android)
PushNotification.prototype.register = function(successCallback, errorCallback, options) {
if (errorCallback == null) { errorCallback = function() {}}
if (typeof errorCallback != "function") {
console.log("PushNotification.register failure: failure parameter not a function");
return
}
if (typeof successCallback != "function") {
console.log("PushNotification.register failure: success callback parameter must be a function");
return
}
cordova.exec(successCallback, errorCallback, "PushPlugin", "register", [options]);
};
// Call this to unregister for push notifications
PushNotification.prototype.unregister = function(successCallback, errorCallback, options) {
if (errorCallback == null) { errorCallback = function() {}}
if (typeof errorCallback != "function") {
console.log("PushNotification.unregister failure: failure parameter not a function");
return
}
if (typeof successCallback != "function") {
console.log("PushNotification.unregister failure: success callback parameter must be a function");
return
}
cordova.exec(successCallback, errorCallback, "PushPlugin", "unregister", [options]);
};
// Call this if you want to show toast notification on WP8
PushNotification.prototype.showToastNotification = function (successCallback, errorCallback, options) {
if (errorCallback == null) { errorCallback = function() { } }
if (typeof errorCallback != "function") {
console.log("PushNotification.register failure: failure parameter not a function");
return
}
cordova.exec(successCallback, errorCallback, "PushPlugin", "showToastNotification", [options]);
}
// Call this to set the application icon badge
PushNotification.prototype.setApplicationIconBadgeNumber = function(successCallback, errorCallback, badge) {
if (errorCallback == null) { errorCallback = function() {}}
if (typeof errorCallback != "function") {
console.log("PushNotification.setApplicationIconBadgeNumber failure: failure parameter not a function");
return
}
if (typeof successCallback != "function") {
console.log("PushNotification.setApplicationIconBadgeNumber failure: success callback parameter must be a function");
return
}
cordova.exec(successCallback, errorCallback, "PushPlugin", "setApplicationIconBadgeNumber", [{badge: badge}]);
};
//-------------------------------------------------------------------
if(!window.plugins) {
window.plugins = {};
}
if (!window.plugins.pushNotification) {
window.plugins.pushNotification = new PushNotification();
}
if (typeof module != 'undefined' && module.exports) {
module.exports = PushNotification;
}
我無法下載任何插件。所以請幫助我。
告訴我如何登記GCM帳戶 以及如何從GCM 以及如何處理上的PhoneGap
請與我分享代碼或解決方案
我已經解決了錯誤 我不會使項目檢查它通過PhoneGap的桌面應用程序 當我爲項目創建APK的APK運行成功 –