Phonegap推送通知类未找到错误

时间:2015-12-31 12:45:08

标签: cordova push-notification google-cloud-messaging phonegap-plugins cordova-plugins

尝试使用phonegap cordova 5.4.1版本与GSM连接,我每次都没有找到错误类别如何解决此问题

我想要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

请与我分享代码或解决方案

2 个答案:

答案 0 :(得分: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

答案 1 :(得分:0)

我已经解决了错误我没有制作apk项目通过phonegap桌面应用程序检查它当我为项目成功运行创建apk