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是的 –