Wednesday, April 3, 2013

What is a Hybrid App?

Hybrid is anything derived from heterogeneous sources, combination of different sources, in different manner, or composed of elements of different or incongruous kinds.

A hybrid app is one that is written with the same technology used for websites and mobile web implementations, and that is hosted or runs inside a native container on a mobile device.

Hybrid apps uses a web view control for corresponding OS (UIWebView on iOS, WebView on Android and others) to present the HTML and JavaScript files in a full-screen format, using the native browser rendering engine (not the browser itself).

WebKit is the browser rendering engine that is used on iOS, Android, Blackberry, i.e. HTML and JavaScript used to design & develop hybrid app, will rendered/processed by the WebKit rendering engine and displayed to the user in a full-screen web view control, not in a browser. 

 Apache Cordova (formerly PhoneGap) is an example of a JavaScript abstraction layer over native APIs. Through this abstraction layer (between native & hybrid) a common set of APIs is exposed in JavaScript, and these JavaScript APIs work on any device supported by the framework (Cordova that is seven mobile platforms including iOS, Android, Blackberry and Windows Phone 7). 

When the native wrapper is compiled around the HTML, CSS and JavaScript resources, there is an interop layer added that connects the JavaScript APIs with the platform specific APIs.

For Example - 

Working with Camera, when we want to take a image through camera, how  it is working in different platform (iOS or Android) -

Under the covers the JavaScript is making an interop call that access the native API for the camera. 

That means that on an iOS device this JavaScript is calling into the native layer to instantiate a  UIImagePickerController and on Android it creates an Intent to use MediaStore.ACTION_IMAGE_CAPTURE to take a picture.

As a developer, no worry about all above stuff (internal calling or internal working process), you just need to call the JavaScript function ( in this case), and respond to the outcome (the imageData passed to the onCameraSuccess call back function in this case).

So, what we conclude - 

Hybrid apps are a great option for you if you:
  1. Want to target multiple mobile platforms
  2. Want to take advantage of device capabilities like geolocation, accelerometer or the camera
  3. Want the app to be useable when the device is offline
  4. Don’t need the advanced graphics performance that you can only get from a native app
Hybrid apps are built with web technologies which means there are millions of web developers who already have the base skill set to build mobile apps.