John Christian De Chavez John Christian De Chavez - 2 months ago 42
Android Question

cordova angular cannot connect to socket.io

My

Ionic
is working with
socket.io
in a webview. But when I try to compile my app to android, it seems that
socket.io
cannot connect to my
nodejs
server.

As I console everything to my node server for connection events, it doesn't trigger the
connection
event as seen below:

io.on('connection',function(socket){
console.log('My socket id is '+socket.id);
});


My node console works properly when I try to run the app in a browser. But using the android app extracted from cordova it seems it cannot connect.

UPDATE: this is my
config.xml
file in my app

<?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="dev@cordova.apache.org" 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>

Answer

i already solved my problem. what i did is to make it work in a simulator so that i can debug or see easily the errors. and i fount out the the path in mobile is always starting in file:// blah blah when i use the native script code to get current path. and thats why its not connecting to my Nodejs Server. and everything is fixed now. thank you! SO'ers.