How to connect to the server on mobile application?

deadshot picture deadshot · May 26, 2014 · Viewed 39.2k times · Source

I am new to mobile applications. I am basically from a web development platform. I am just playing around mobile frameworks like App Framework, LungoJS, Jquery Mobile, kendo etc to gain some knowledge in this vertical.

The app I am developing is still in UI level. All I need is to fetch data from the server and populate in my app.

I need some ideas to establish server communication between the smart device and the server. My questions are

  1. What kind of server needed for mobile applications ? A cloud or a regular web server is enough ?
  2. What are the ways to connect the app with the server ? ( on cross platform mobile development )
  3. What is the secure way to communication with the server ?

Answer

Gajotres picture Gajotres · May 26, 2014

What kind of server needed for mobile applications ? A cloud or a regular web server is enough ?

Because you are creating a hybrid mobile application you can use any type of server side technology, it doesn't matter is it a classic web server technology (using Java, PHP or .NET) or some kind of cloud technology like Parse.com.

You also don't need to create anything from scratch. Best course of action would be to use some kind of micro RESTFul framework(like PHP Falcon or Java Play Framework). Read more about them here.

But, there's always a but. You can't use server side technology for classic content generation, you only need to use it to send data to your hybrid application. I will explain this later.

There's also an alternative to RESTFul services, you can create a webservice, again using Java, PHP or .NET.

What are the ways to connect the app with the server ? ( on cross platform mobile development )

You would use AJAX as a technology (in case of RESTFul), rest depends on you. You would probably do it in JSON format (or JSONP if you are doing cross-domain calls, but you don't need to think about JSONP when creating a hybrid application).

If you intend to use a web service then you would use a SOAP connection and communicate via XML format.

No matter which server side technology you use you will always use AJAX on a client side.

Now let me tell you why you should not generate your content on server side. Basically nothing can prevent you from doing that, you can generate your complete page on web server and just show it in PhoneGap app, it would still be a hybrid app. But, if you try to put this app in Apple store you will get yourself rejected.

What is the secure way to communication with the server ?

Security of course depends on server side technology. Every framework has its own kind of security handling, but all of them relay on HTTPS so you should not worry too much.

From the client side you can always encrypt JSON/XML data and send them using POST.

Examples:

If you want to use jQuery Mobile then take a look at this tutorial. It will show you basics of client - server side communication.