2016-05-27 5 views
0

pushwooshでプッシュ通知のチュートリアルに従いましたhereです。Cordovaはpushwooshで定義されていません

index.jsファイルにjs関数を追加しました。

function initPushwoosh() 
     { 
      var pushNotification = cordova.require("pushwoosh-cordova-plugin.PushNotification"); 

      //set push notifications handler 
      document.addEventListener('push-notification', function(event) { 
       var title = event.notification.title; 
       var userData = event.notification.userdata; 

       if(typeof(userData) != "undefined") { 
        console.warn('user data: ' + JSON.stringify(userData)); 
       } 

       alert(title); 
      }); 

      //initialize Pushwoosh with projectid: "GOOGLE_PROJECT_NUMBER", pw_appid : "PUSHWOOSH_APP_ID". This will trigger all pending push notifications on start. 
      pushNotification.onDeviceReady({ projectid: "XXXXXXXXX", pw_appid : "XXXXXXXX" }); 

      //register for pushes 
      pushNotification.registerDevice(
        function(status) { 
         var pushToken = status; 
         console.warn('push token: ' + pushToken); 
        }, 
        function(status) { 
         console.warn(JSON.stringify(['failed to register ', status])); 
        } 
      ); 
     } 

私はプラグインを正常に追加しました。しかし、アプリケーションは、デバイス上で動作していないし、ブラウザで私は、次のメッセージが出ます:

Uncaught ReferenceError: cordova is not defined 

どのようにこの問題を克服するために?

答えて

0

PushWooshのサンプルアプリケーションでは、「com.pushwoosh.plugins.pushwoosh.PushNotification」コードバプラグインが必要ですが、ドキュメントでは「pushwoosh-cordova-plugin.PushNotification」を使用しています。

あなたが名前= "pushwoosh-PGB-プラグインを" プラグインを使用する場合

"pushwoosh・コルドバ - plugin.PushNotification" を使用し、その後、あなたの設定ファイルに名前= "pushwoosh-コルドバ・プラグインを" プラグインを使用する場合設定ファイルで "com.pushwoosh.plugins.pushwoosh.PushNotification"を使用してください。

関連する問題