android - AeroGear UnifiedPush Cordova register devices -
i have deployed unifiedpush on jboss 6.4, can access admin ui , create new apps. m trying build new app, in order test push notifications admin console. i'm using phonegap , building android platform. i'm executing on genymotion android emulator.
this index.html page:
<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 events required on startup. common events are: // 'load', 'deviceready', 'offline', , 'online'. bindevents: function() { document.addeventlistener('deviceready', this.ondeviceready, false); }, // deviceready event handler // // scope of 'this' event. in order call 'receivedevent' // function, 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 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 device</p> <p class="event received">device ready</p> </div> </div> <script type="text/javascript" src="cordova.js"></script> <script>app.initialize();</script> </body> </html>
the problem on unifiedpush admin console no device registered. error: connectexception: failed connect localhost/127.0.0.1 (port 8080) after 30000ms: isconnected failed:econnrefused (connection refused).
wrong?
solution: pushserverurl
can't "http://localhost:8080/ag-push/"
, need set local ip machine server running. (e.g. "http://192.168.1.2:8080/ag-push/"
).
Comments
Post a Comment