首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >AeroGear UnifiedPush Cordova寄存器设备

AeroGear UnifiedPush Cordova寄存器设备
EN

Stack Overflow用户
提问于 2016-11-17 14:23:09
回答 1查看 83关注 0票数 0

我已经在JBoss6.4上部署了UnifiedPush,我可以访问管理ui并创建新的应用程序。我试图构建一个新的应用程序,以测试推送通知从管理控制台。我正在使用PhoneGap并构建安卓平台。我正在Genymotion模拟器上执行它。

这是我的index.html页面:

代码语言:javascript
运行
复制
    <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).,出了什么问题?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-11-19 12:42:02

解决方案:pushServerUrl不能是"http://localhost:8080/ag-push/",您需要在服务器运行的地方设置本地ip机器。(如"http://192.168.1.2:8080/ag-push/")。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/40657363

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档