0
我的Ionic
正在与web浏览器中使用socket.io
。但是,当我尝试编译我的应用程序到Android,似乎socket.io
无法连接到我的nodejs
服务器。cordova angular无法连接到socket.io
正如我安慰一切为连接事件我的节点服务器,它不会如下图所示触发connection
事件:
io.on('connection',function(socket){
console.log('My socket id is '+socket.id);
});
我的节点主机正常工作时,我尝试在浏览器中运行应用程序。但使用从科尔多瓦提取的android应用程序似乎无法连接。
UPDATE:这是我3210文件在我的应用程序
<?xml version='1.0' encoding='utf-8'?>
<widget id="com.myapp.pagemanager" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
<name>PageManager</name>
<description>
A sample Apache Cordova application that responds to the deviceready event.
</description>
<author email="[email protected]" href="http://cordova.io">
Apache Cordova Team
</author>
<content src="index.html" />
<plugin name="cordova-plugin-whitelist" spec="1" />
<access origin="*" />
<allow-intent href="http://*/*" />
<allow-intent href="https://*/*" />
<allow-intent href="tel:*" />
<allow-intent href="sms:*" />
<allow-intent href="mailto:*" />
<allow-intent href="geo:*" />
<platform name="android">
<allow-intent href="market:*" />
</platform>
<platform name="ios">
<allow-intent href="itms:*" />
<allow-intent href="itms-apps:*" />
</platform>
</widget>
您使用的是离子吗? –
你使用'socket.io-client'作为你的依赖吗?您是否将服务器域列入了白名单(例如,查看[白名单]的cordova文档(https://cordova.apache.org/docs/en/latest/guide/appdev/whitelist/index.html))? – Beat
@DevidFarinelli是的 –