我有一个使用phonegap构建开发的移动Web应用程序。 我将其打包为一个ipa和apk文件,并且代码在浏览器中运行。 我有一个对于在远程服务器上运行的功能至关重要的数据库。
我能够使用websockets连接到服务器,而在iOS设备,浏览器甚至移动浏览器中都没有问题。 但是,打包的apk无法连接到服务器。
我尝试确保白名单正确,并添加了一些附加条件,因为它代表config.xml访问,如下所示:
我还在index.html中添加了内容策略元标记,如下所示:
似乎都没有影响该问题。
我已经下载了android studio,并尝试使用设备和仿真器进行调试,但是该软件无法调试javascript。
我尝试使用chromes远程调试,并且可以显示设备和仿真设备选项卡,但是如果我启动该应用程序,则什么也不会出现。
我将所有首选项和插件放在这里,以防万一可能是问题所在:
我认为这是一个phonegap构建配置问题,因为它可在iOS而不是android上运行。
这也可能是javascript的websocket问题? 我项目的Net类首先开始,但从未达到初始化完成。 这是代码:
connect()
{
var that = this;
var wsstring = "ws://" + that.host + ":" + that.port + "/" + that.frag;
that.ws = new WebSocket(wsstring);
that.ws.onopen = function()
{
that.sendMessage("hello","Hello, world");
that.heartBeat();
app.logger.setup();
console.log("Logger Activated!");
};
that.ws.onmessage = function (evt)
{
that.messageHandler.handleMessage(evt.data);
};
that.ws.onclose = function()
{
that.ws = null;
console.log("WebSocket Closed");
setTimeout(function(){ that.connect }, 1000);
}
that.ws.onerror = function (err)
{
console.error('Socket encountered error: ', err.message, 'Closing socket');
that.ws.close();
}
that.ws.closed
}
任何建议将不胜感激!