Reputation: 67
I want to develop an hybrid cross platform app that creates a socket connection to given Ip. I have achieved it using webTCP module in node.js by running node from cmd to start the server. Now I want to pack this in to an app using Phonegap. But my question is how do I run node(to start server) in mobile through the app created using phonegap. Do we need to install node in mobile. If so how can I do that? Thanx in advance.
Upvotes: 2
Views: 1106
Reputation: 353
nodejs isn't done (yet) to run on Android. NodeJs is a server thing so it should run on your server to run tour backend.
In order to do what you want to do you will have to redesign your architecture.
Indeed, Cordova/PhoneGap is a little server (actually it's is a WebView but you can approximate it to a static content delevery server). So you will have to made your cordova app talk to your node-server.
Cordova-app <- INTERNET -> Node-server
The first thing to do is to enable CORS, for nodejs and whitelist the adress of your node-server in cordova
Now you can start talking to your server with your cordova app, there is many ways to do that :
You will need more powerful feature between your app and your server side. In order to do that, you could need some WebApp framework. Indeed, they automate for you the connection between the server and your application and offer you a cool and easy environment to do great apps. If you want to know more about it, you could look at
Hope that help.
Upvotes: 4