Phonegap (1.7.0) + node.js + socket.io - android

I am trying to build an Android (v.4.0.3) app with Phonegap (Cordova 1.7.0), Node.js (v0.6.18) and Socket.io (v0.9) on the other side. I need to do this for my school project, but I hit a wall due to my limited knowledge. I even thought that socket.io can’t be used within Phonegap (Android). Would it be possible to get some directions, link or other kind of help so that I would be able to establish connection. Connection is the main problem. The documentation is not helping me enough.
I would really appreciate some tips on how to establish a connection. I installed node inspector, but nothing. Server.js is running on an Amazon EC2 micro instance on port 8080.
I read somewhere that Android doesn't support websockets.
But isn't it true that Phonegap actually grabs the whole HTML page and packages it up to run as a native application within a UIWebView or WebView?
So in that case it is the webkit. And this one supports websockets if I am not mistaken.
Regards,
Tomaz

There's a Phonegap plugin for websockets.

This question was asked almost 3 years ago though. If you need to use node.js and cordova/phonegap together on Android or iOS see jxcore-cordova

Related

Html css cross-platform vpn service on android and ios

I'm trying to make an application getting my user connected to my vpn on ios and android
The problem is that after 5 hours on google, I didn't find anything.
With ionic, no one did It, no topic has an end.
With react native, the same problem.
There still is xamarin, but i'm not even sure it work because there is no working example.
If you have done an application like this, with which framework have you done a cross platform application performing a vpn connection ? Thanks

is it possbile to run local server on mobile device using phonegap?

I want to create client/server offline application. Server should be hosted on a mobile device. Other devices throught a browser should get some content from serrver. Is it possible at all? Is it possible using phonegap? Could anyone give me advice about it?
I use this chrome plugin in a couple of enterprise apps:
https://www.npmjs.com/package/cordova-plugin-chrome-apps-socket
It works on Android and iOS, is very stable, and you can use it as socket server/client and also as webserver.
Update:
First: If you are developing Cordova-Apps, then make a decision what you want to use (Cordova, Phonegap, Ionic, …). Don't mix things and read the documentations.
Second: If you want to install a Cordova plugin from npm, the syntax is:
cordova plugin add [npm-name]
For installing the chrome-sockets-plugin, use:
cordova plugin add cordova-plugin-chrome-apps-socket
Before you start writing a server-client-socket app with this plugin, read the full documentation from Google. It is not a task which works out of the box and needs some lines of code and some experience in Javascript.

WebRTC using Peerjs with Native Android/iOS clients

We're trying to build an internal system which will provide us with simple chat/video features using WebRTC. We have successfully deployed Peer.js client and server which works great over the browser.
However, we can't seem to find a fairly simple Android/iOS client/SDK to make it compatible with our PeerJS server.
We've tried looking into AppRTC and got the Android client running with their server, however we can't understand how to connect it to our PeerJS server since that Android client (and server implementation) seems really complicated (we're not JAVA experts).
I've also looked into EasyRTC, however it seems that they've pulled back their native SDKs, but the technology stack looks really close to ours.
My question is, has anyone got and Android/iOS Client working with WebRTC running on a NodeJS server? What are the possible workarounds to get this up and running natively on Android?
We're looking for a fairly simple Android SDK (links to libraries/sample projects) which could work with a PeerJS server.
Edit: We could build a signaling server (on NodeJS) ourselves, but how can we build the Android/iOS clients from then on?
I'm offering a bounty of 200 rep to whoever can answer our questions.
I don't know PeerJS but it seems like using websockets. If that's the case you have to implement WebSocket client functionality in you native clients (and various PeerJS internal connection/signaling protocol).
For native to native signaling, it's really simple because we only have to exchange SDP and ICE candidate messages between clients (via WebSocket or any other messaging mechanisms).
To connect to PeerJS server, obviously, we need PeerJS client implemented in Java or C(ObjC).
I'll be surprised if such implementation or SDK exists.
I don't know current state of AppRTC source, but in its old version, it hosted a WebView to run a kind of HTML+JavaScript signaling client.
That is, you can host a WebView and reuse your PeerJS client in Android/iOS apps.
You can have look at Crosswalk project. By follow Tutorial: porting Android app from Web App for WebRTC using PeerJS library. I have done it and it worked perfectly.
There are another option which is using http://phonegap.com/ to port from web app to Android/iOS but I could not make it work event just with "getUserMedia" API.
Hope this help
I found a example in here https://github.com/pchab/AndroidRTC1
On the server they used nodejs + socket.io + AngurlarJs.
On the client they used libjingle_peerconnection + socket.io Client.

phonegap development environment

I'm trying to get setup to do mobile development using phonegap so i can deploy my application in android store and apple store. It's my understanding that I can simply wrap my application in phonegap so I can deploy for Android, iOs, BB, etc.
My application is an ASP.Net MVC app written with VisualStudio. All of the examples I've read through in my research tells you to use Eclipse for PhoneGap and Android, use XCode for PhoneGap and iOs. My app is ASP.Net MVC that produces Html 5. Is it possible to use PhoneGap with VisualStudio to produce Android and iOS deployable phonegap apps?
One alternative I've been thinking about is creating a simple Index.html page that uses jQuery to make a call to my ASP.Net MVC app and load the resulting HTML inside a div. Then I can simply reproduce this very lightweight Index page in Eclispe, XCOde, etc to run through Phonegap. This seems like a hack though. I've tried getting this to work but have not had any luck in the Android emulator in my windows environment.
Can someone please point me in the right direction for how to incorporate PhoneGap with my ASP.Net MVC app? Thanks.
ASP.NET lives on your server, so anytime you reference any ASP.NET script, you'll have to make the URL an absolute one with a hostname: http://www.example.com/my-script.aspx. Any non-dynamic files should be stored locally on the device so they will function when there is no network connection. You can then just host the dynamic files on your server and reference them whenever you need to. To keep data transfer size as small as possible, I generally pass JSON or something similar to the app. from my server-side script and then interpret the data into HTML in the JavaScript code for the app.
You should keep as many assets as you can local on the device so it doesn't require an internet connection to use the app. So don't link to a remote version of jQuery, save it as a part of the app. package you create so it's always available.
Eclipse/Xcode are nice because they help you create your app. and package it properly for submission to app. stores. They are also nice because of how easy it is to find help using Eclipse or Xcode to create apps. Xcode is actually required, Apple makes sure you have bought the latest hardware and the latest software just to be able to submit an app. to the store.

WebSockets for Android in Phonegap application with Node.js/Socket.IO server&client

I am making an Android application in PhoneGap. What I'm trying to do is let the application talk to my Node.js server through WebSockets. My Node.js server uses Socket.IO which automatically falls back to polling when I open the application up, in contrary to the desktop Chrome application which happily opens up a WebSocket and communicates through it just fine.
I've read this blogpost about integrating the actual WebSocket API with Phonegap. The problem there is that I'm not overriding 'onConnect, onMessage' functions manually, instead Socket.IO does all that for me.
Is there some way to integrate WebSockets into my Android Phonegap application?
Short answer: Cordova WebView doesn't support WebSockets and socket.io doesn't connect to standards-based WebSocket clients.
For your client, it still appears that if you want real websockets, you need to use a Cordova plugin that is specific to an Android build or an iOS build. Try this search, which includes anismiles repo for an Android plugin, the same blogger referenced by the OP.
So with that in mind, socket.io will not work for your server. Unfortunately, socket.io server does not support connecting to clients with an Html5 standards-based websocket connection, you have to use their client library. As you've seen, you can't use their client library in Cordova...well you can, it'll just fallback to polling.
So now your websocket client is a standards-based Cordova plugin, you need a server that supports a standards-based websocket connection. You should take a look at SockJs, Worlize, Miksago, or Einaros. There are others. I'm currently using Worlize.
Another thing to keep in mind is that there is a short list of cloud hosts currently supporting true websocket connections. I recommend DotCloud or Nodejitsu.
If this answers your question please click the check mark :)
Updating the answers, this plugin works with socket.io and it's much easier to use (PhoneGap 3.x only).
https://github.com/mkuklis/phonegap-websocket
This repository will be integrated in phonegap very soon (at least it sounds like that in the readme)
It also also provides the steps for making web sockets work in phonegap / android.
Take a look: https://github.com/anismiles/websocket-android-phonegap
Here is another websockets Android client, that I am currently evaluating.
http://jwebsocket.org/mobile/android/android_part1.htm
I'm afraid I have no idea if it will be useful to a phonegap project, not being familiar with it.
Phonegap would need to allow you to incorporate an external java library into your project and you would need to build an interface for it in java.

Categories

Resources