1

嘗試與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

請與我分享代碼或解決方案

+0

我已經解決了錯誤 我不會使項目檢查它通過PhoneGap的桌面應用程序 當我爲項目創建APK的APK運行成功 –

回答

0

你必須將其添加爲發送通知一個功能和插件。 欲瞭解更多詳情,您可以檢查的PhoneGap PushPlugin:https://github.com/phonegap-build/PushPlugin/issues/119

您還可以檢查推送通知與PhoneGap的,如何設置推送通知:http://www.adobe.com/devnet/phonegap/articles/android-push-notifications-with-phonegap.html

+0

我已註冊GCM設備BU t顯示InvalidRegistration的帖子請幫助 –

+0

服務器端的註冊ID應與客戶端生成的註冊ID相匹配。檢查它們是否相同。查看此頁面,瞭解如何獲取API密鑰。 (https://developers.google.com/cloud-messaging/) –

+0

請檢查您在清單文件中的權限。您可以查看官方文檔,以下鏈接:https://developers.google.com/cloud-messaging/ –

0

我已經解決了錯誤我不會使項目的APK檢查它通過PhoneGap的桌面應用程序,當我爲項目創建APK它成功運行