I'm in the process of building a Cordova application that needs to talk to a hardware device I'm building. The device can transmit HTTP requests, but can't accept requests. Both the app and device are the only devices on the local network with no internet access.
Are there anyways for the Cordova application to receive incoming HTTP requests from the hardware device?
If it helps the app needs to support Android (with iOS coming out in the near future).
Found a plugin that does what I need - https://github.com/driftyco/cordova-plugin-discovery
Props to eduyayo for putting me on the right track
Related
I've faced an issue with creating any kind of servers under Cordova application. Wondering if it possible at all.
Scenario
Let's imagine that we have a decentralized network of devices (tablets, phones) from one tablet to a huge network of 20+ devices and can be more. These devices must handle synchronization between each other and it can be implemented as HTTP server or WebSocket server, etc...
Each device have installed Cordova application and our goal is to make these devices discoverable in a network (I was thinking about UDP datagrams for discovery) and these devices must synchronize data between them (simple TCP connections and JSON objects).
Question
For this scenario we need to have an access to a network layer in Cordova application. So, our Cordova application when running onto device can be as server and as client as well. The question here is how to implement UDP\TCP server in Cordova application, since we have only client implementations?
P.S. I was trying plugins like cordova-plugin-chrome-apps-udp, cordova-plugin-websocket and cordova-plugin-websocket-server but it still doesn't work properly (I'd like to say it's not working at all)
I am building a Hybrid Mobile Application using IONIC Framework. My problem is that my client is septic of using GCM and APN and asks to get a solution for PUSH notification independent of these two. So something inhouse needs to be build. I have two problem and a few questions about the same.
Can web sockets help in giving the same functionlities that APN & GCM provide.
If I use websockets in some fachion can I achieve PUSH Notification on the mobile application even if the app is closed but user's session persists.
Can we build a PUSH server inhouse? If yes where can I find the specs according to OS of the Phone.
I am well aware of Web Sockets, can it help for the above purpose?
Point me to the specs required to Build such a server and how would I go ahead to configure with Ionic if possible.
I would be using NodeJS, Mongo/Redis with web sockets.Thats what I am thinking please let me know if its otherwise and how to achieve.
Thanks
It's a lot of push service system that some of them is free and some of them are not
Also, you can implement by yourself, you need to have the server to support WebSocket then In application layer you need to connect to server (e.g, Service in android) and create your own broadcast to handle data came from WebSocket
Some point you need to remember :
- Your application always needs to connect to your WebSocket link (battery life issue and network listener)
- You must be sure that application always runs (e.g, when the device restarted [use android.permission.RECEIVE_BOOT_COMPLETED])
how can I execute HTTP requests or open a socket on Android Wear? I used to think that's impossible but the Web Browser for Android Wear app says the folloing:
"[..] works even when your phone is off if you have a smartwatch with Android Wear 5.1 and WiFi"*.
I tested it and that app CAN connect the internet when the paired phone is powered off.
Whenever I open a socket or try HTTP requests on Android Wear I always get a ConnectException saying failed to connect to http://foo.com (similar stack trace here). So I'm doing something different then that app is doing and I'd like to understand what that is.
Context: I'm working on proof-of-concept and just want to be able to execute HTTP requests and open sockets. I'd love to know if there's any way to do that. Even if it includes rooting the watch and doing some adb magic.
To clarify: I know about the Data Layer API and i'd still like to be able to just do HTTP requests and open sockets.
If your watch has Wifi and it is set up correctly, then you can make network calls on your watch when your watch is disconnected from the phone; when you connect to your phone via BT, wifi will be disabled. While it is enabled, you should be able to treat that as a usual network connectivity and make network calls. But keep in mind that if you write an app that relies on this, your app will fail to work when it gets connected to a phone so you need to handle that case and provide an alternative for your app to get the same data (i.e. using the phone's connectivity).
My question is how to create a web service on android device & host it on the mobile device.
I don't want to access an already created webservice deployed on a server; I want to create a webservice that returns json/xml & host it on mobile.
RESTful Web Services Implementations in Mobile Devices says it's doable for Java-based mobile devices, so I think it can be done for Android too.
There is one problem with your setup and mobile devices: mobile networks (wifi and 3g) mostly use NAT, which prevents inbound connections. This makes mobile devices inaccessible from the internet (inbound) while they can still initiate outbound connections. For this reason mobile devices mostly do not host servers.
What you can do is make an Android service which pings a server ( a web-server) every 30 minutes or so simply send a bit from client to server and back to check the availability of request from another phone. This way you can upload media files to server and download them to your another device.
I am trying to solve the same problem and I am leaning towards https://github.com/NanoHttpd/nanohttpd.
It is a tiny webserver without any REST or MVC functionality, thus you would have to write it yourself (MVC, content negotiation, etc).
I developed an app for android tablet, Now i need to perform certain actions on the app through my android phone using WLAN... How to do it?
Your app can create a server socket to receive client requests, and then interpret commands that your remote client sends to it. This page might help you with the Android server socket part of things.