A common application for the Internet of Things is sending data to some cloud service, for further processing storage and analysis. Data analysis and Business intelligence are important areas for IoT. This guide helps you sorting out the options for communication with cloud servers from a mobile app.
One thing to be aware of when writing code that communicates with servers from a web page is that web protocols come in two flavours, standard HTTP (non-encrypted data transfer) and HTTPS (encrypted secure data transfer).
The tricky part is that an app loaded over HTTPS is not allowed to access resources over HTTP, you must use HTTPS also when loading images, css, scripts, and when using XHR. Web views only allow secure connections from a securely loaded page. This is something to keep in mind when working with Evothings Studio, since Evothings Viewer uses HTTPS to communicate with the server that hooks up to the Workbench.
Similarly if you are using WebSockets (WS) you must use Secure WebSockets (WSS).
To sum it up, if you need to access data on a server, the server must support HTTPS or WSS (WebSocket Secure) and it must be configured with a proper certificate (not self signed) and the certificate must include all intermediates. This is because the Evothings Viewer does not bundle a lot of the known intermediates, as a regular browser typically does.
To work around this restriction for regular HTTP requests, the Cordova HTTP plugin can be used. See below for further details.
Keep in mind that the server must support HTTPS when you use Evothings Studio (see section above for explanation).
Using the plugin cordova-HTTP you can access and download data from any server, without HTTPS/HTTP restrictions or cross-origin restrictions.
With this plugin the app can fetch JSON data, HTML code, basically any text-encoded data. Fetching binary data is not supported. You can also upload JSON data with this plugin.
The HTTP plugin is included with Evothings Viewer.
The Mobile Chrome Apps socket plugins can be used to access data and communicate with servers using the basic TPC protocol. The UPD protocol is also supported, but is not commonly used by IoT Cloud services.
Have a look at the API reference for the Chrome Socket TCP plugin.
This plugin is included with Evothings Viewer.
As a final option for communicating with servers and Cloud services, you can write a custom Cordova plugin. Consult the Apache Cordova documentation for an overview of how to make your own plugin.