15

I'm developing an IOS app using phone gap and I'd like to use node.js for part of it. Is it feasable to get phonegap to run an instance of node.js along side the rest of the app?

devnill
  • 2,043
  • 4
  • 21
  • 31
  • If you elaborate on your design idea you'll probably get better feedback. – Pointy Jan 24 '13 at 23:56
  • Do you mean you want to run a node.js server on the phone and point PhoneGap at it? – Jason Sperske Jan 24 '13 at 23:59
  • 1
    @JasonSperske: Yes, exactly. The client wants a nodejs back end to handle outgoing smtp. – devnill Jan 25 '13 at 01:18
  • I don't know about phonegap, but there are efforts to bring node.js onto phones: https://github.com/paddybyers/anode and http://mitchtech.net/node-js-on-android-linux/. (Taken from http://stackoverflow.com/questions/11392590/how-to-run-my-node-js-project-on-android) – Turion Feb 02 '14 at 12:48
  • This was essentially a yes/no question and no one gave a straight answer. Can you or can you not use node.js functions such as base64 encoding with your Cordova apps? – andreszs Apr 26 '17 at 11:57

2 Answers2

20

Phonegap is a client-side solution only with JavaScript/CSS/HTML running on the browser-app of the phone. The JavaScript Phonegap API talks to the native phone interface and browser interface which gives you options to work natively and as a normal web page would with enhanced permissions. Node.js would only serve you as a data connection for JSON or whatever else you would need to pull/push with a network call.


UPDATE: @Turion had a great comment and made me look a little deeper. Here's what the stack and google came up with:

Native IOS app and node.js

and direct YouTube link to neu.Node (Node runnning on iphone!!!) http://www.youtube.com/watch?v=xzFH80-HYTo

Community
  • 1
  • 1
King Friday
  • 25,132
  • 12
  • 90
  • 84
  • 1
    That's what I figured. Just making sure because that was what the client wanted. – devnill Feb 22 '13 at 21:34
  • 3
    There are usecases where you'd like your phone to be a server, though. For example when connecting other phones to it or when communicating with other devices (roboters, drones). I was actually hoping to be able to develop a node.js application running on a phone, controlling a Parrot AR Drone using this node.js library: https://github.com/felixge/node-ar-drone – Turion Feb 02 '14 at 12:44
  • 2
    I actually agree with you that there should be. I removed the "nor should it (BS)" I wrote. Not sure what smug train I was on to write that but we all have our moods I guess. Since ios has Unix flavored and I am absolutly in love with node.js, I thought yah why not? I put a reference on this to another post about this. Thanks for the comment. Got me thinking. – King Friday Feb 02 '14 at 21:35
  • 1
    couldn't you build a restful api with node.js and have your phonegap app make requests to that? I'm trying to figure out how to use a database with cordova – Connor Leech Feb 26 '14 at 05:19
  • yes, any web server tech can do that. you could consider socket.io for doing quicker real time communication. – King Friday Feb 26 '14 at 05:50
2

This might be helpful:

http://phonegap.com/blog/build/phonegap-build-api-for-node/

phonegap-build-api-js is a published NPM module for accessing the PhoneGap Build API with node.js. It abstracts the HTTP communication, deals with the API quirks, and leaves the rest untouched. In other words, it simplifies accessing the PhoneGap Build API, so that you can focus on integrating it with your product.

Rodrigo Calix
  • 627
  • 1
  • 7
  • 16