2016-11-17 10 views
0

私はJboss 6.4上でUnifiedPushを導入しました。私はadmin uiにアクセスして新しいアプリケーションを作成できます。 管理コンソールからプッシュ通知をテストするために新しいアプリを作成しようとしています。私はPhoneGapとアンドロイドプラットフォームのための建物を使用しています。 私はGenymotion Androidエミュレータで実行しています。AeroGear UnifiedPush Cordova登録デバイス

これは私のindex.htmlページです:

<link rel="stylesheet" type="text/css" href="css/index.css" /> 
     <title>Hello World</title> 

    <script> 
    var app = { 
    // Application Constructor 
    initialize: function() { 
     this.bindEvents(); 
    }, 
    // Bind Event Listeners 
    // 
    // Bind any events that are required on startup. Common events are: 
    // 'load', 'deviceready', 'offline', and 'online'. 
    bindEvents: function() { 
     document.addEventListener('deviceready', this.onDeviceReady, false); 
    }, 
    // deviceready Event Handler 
    // 
    // The scope of 'this' is the event. In order to call the 'receivedEvent' 
    // function, we must explicitly call 'app.receivedEvent(...);' 
    onDeviceReady: function() { 
     app.receivedEvent('deviceready'); 
     var pushConfig = { 
     pushServerURL: "http://localhost:8080/ag-push/", 
     android: { 
      senderID: "admin", 
      variantID: "...", 
      variantSecret: "..." 
     } 
     }; 
    push.register(app.onNotification, successHandler, errorHandler, pushConfig); 

    function successHandler() { 
    console.log('success') 
    } 

    function errorHandler(message) { 
    console.log('error ' + message); 
    } 
    }, 
    onNotification: function(event) { 
    alert(event.alert); 
    }, 
    // Update DOM on a Received Event 
    receivedEvent: function(id) { 
    var parentElement = document.getElementById(id); 
    var listeningElement = parentElement.querySelector('.listening'); 
    var receivedElement = parentElement.querySelector('.received'); 

    listeningElement.setAttribute('style', 'display:none;'); 
    receivedElement.setAttribute('style', 'display:block;'); 

    console.log('Received Event: ' + id); 
    } 
    }; 

    </script> 

</head> 

<body> 
    <div class="app"> 
     <h1>PhoneGap prova</h1> 
     <div id="deviceready" class="blink"> 
      <p class="event listening">Connecting to Device</p> 
      <p class="event received">Device is Ready</p> 
     </div> 
    </div> 
    <script type="text/javascript" src="cordova.js"></script> 
    <script>app.initialize();</script> 
</body> 

</html> 

問題がUnifiedPush管理コンソール上で何のデバイスが登録されていないということです。 このエラーが発生します:ConnectException: failed to connect to localhost/127.0.0.1 (port 8080) after 30000ms: isConnected failed:ECONNREFUSED (Connection refused). どうしたのですか?

+0

あなたのconfig.xmlを見せてください –

+0

http://pastebin.com/RsuC0cmJここは私のconfig.xmlです@HassanALi – slash89mf

+0

config.xmlの開始ページをまたはapp内からcdvtes​​ts/index.htmlに移動します。再度訪問してくださいhttps://github.com/aerogear/aerogear-cordova-push –

答えて

0

解決方法:pushServerUrl"http://localhost:8080/ag-push/"にはなりません。サーバが稼働しているローカルIPマシンを設定する必要があります。 (例えば、"http://192.168.1.2:8080/ag-push/")。

関連する問題