Tuesday, April 9, 2013

Hybrid app development PhoneGap

Creating mobile apps is a trend nowadays. we've chosen PhoneGAP for creating mobile apps to look at more closely. So, let’s start. but big question is should we use native app or hybrid app or HTML5 based webapp.

PhoneGap application is a “native-wrapped” web application. Let’s explore how the web application is “wrapped”.

Many native mobile development SDKs provide a web browser widget (a “web view”) as a part of their UI framework (iOS and Android, for example). In purely native applications, web view controls are used to display HTML content either from a remote server, or local HTML packaged along with the native application in some way. The native “wrapper” application generated by PhoneGap loads the end developer’s HTML pages into one of these web view controls, and displays the resulting HTML as the UI when the application is launched.

If JavaScript files are included in a page loaded by a web view, this code is evaluated on the page as normal. However, the native application which creates the web view is able to (in different ways, depending on the platform) asynchronously communicate with JavaScript code running inside of the web view. This technology is usually referred to as “the bridge” in the context of PhoneGap architecture – the “bridge” means something slightly different in Titanium, as we will see later.

PhoneGap takes advantage of this to create a JavaScript API inside a web view which is able to send messages to and receive messages from native code in the wrapper application asynchronously. The way the bridge layer is implemented is different per platform, but on iOS, when you call for a list of contacts, your native method invocation goes into a queue of requests to be sent over the bridge. PhoneGap will then create an iframe which loads a URI scheme (“gap://”) that the native app is configured to handle, at which point all the queued commands will be executed. Communication back into the web view is done by evaluating a string of JavaScript in the context of the web view from native code.
There is much more to PhoneGap than that, but the messaging from web view to native code via the bridge implementation is the key piece of technology which allows local web applications to call native code.There’s quite a bit happening behind the scenes in a Titanium application. But basically, at runtime, your application consists of three major components – your JavaScript source code (inlined into a Java or Objective-C file and compiled as an encoded string), the platform-specific implementation of the Titanium API in the native programming language, and a JavaScript interpreter that will be used to evaluate your code at runtime (V8 (default) or Rhino for Android, or JavaScriptCore for iOS). Except in the browser, of course, where the built-in JavaScript engine will be used.

So major differences are:

PhoneGap:

  • JavaScript API that provides access to Native Functions
  • Supports HTML5/CSS3
  • Supports Web Standards & Re-use Across Enterprise Apps
  • Supports DOM based JavaScript Libraries/Frameworks
  • Supports the most platforms

Appcelerator Titanium:

  • JavaScript API that provides access to Native Functions
  • Compiles to Native Code
  • Could provide better performance.

Issues:

Of course, both Titanium and Phonegap fall into the category of “hybrid” but the key difference is implementation: while Phonegap application runs inside browser, Titanium’s app runs inside javascript interpreter. Runtime performances are SLOWER than native code because it's using a javascript engine as a bridge. Especially with a big TableView, it's much more slower, and the feeling is just not the same.

I have build two diff applications based on phonegap for testing purpose and i found that both are very slow as compare with browser rendering. When i cross checked same application in my phone's browsers, it looks much responsive than in app. Might be current browsers are using hardware acceleration by default. I have used mobile Jquery & phone gap APIs for demo.




I know that jquery mobile can be a little slow by nature, imagine my surprise and disappointment when my compiled phonegap app UI is magnitudes slower running on my phone than running in the phone's native browser. How can the compiled app be so noticeably less responsive than the same app running in the phone's native browser? The responsiveness is completely unacceptable.

http://apachecordova.blogspot.in/2012/11/who-is-murdering-phonegap-its-jquery.html

Even phonegap provide better solution to use JS Framework.

11 comments:

  1. It was Excellent and very informative. Its really very useful post. I found a lot of informative stuff in your article. Keep it up.

    android application development companies

    ReplyDelete
  2. It's very easy to find out any topic on net as compared to textbooks, as I found this article at this site.

    My blog post: http://www.puertoricotkd.com/

    ReplyDelete
  3. Ecommerce websites attract thousands of buyers by offering great deals and better prices.Lots of ecommerce websites are being developed in order to fulfill market demands.Ecommerce Website Development

    ReplyDelete
  4. I constantly emailed this weblog post page to all my associates, because if like to read it then my links will too.


    Feel free to visit my webpage ... cerramientos

    ReplyDelete
  5. With every hand using smart phone and its extensive features, the need for mobile presence is so well known. The market is competitive and to create a competitive edge above the rest, you need experts. With every hand using smart phone and its extensive features, the need for mobile presence is so well known. The market is competitive and to create a competitive edge above the rest, you need experts. Learn more about Mobile Application Development India visit our website

    ReplyDelete
  6. Thiѕ hаѕ cаused me to consider if there's a few areas I could do things in a more focused way.

    My webpage; cheappersonalloans.me.uk

    ReplyDelete
  7. I purchased a similaг domain to this а fеw daуs agο, hoping to aԁd somеthіng a little different to
    this ѕubject.

    My ωеb-site Unsecured Personal loans

    ReplyDelete
  8. hello,
    Phonegap is mostly used because it has some very good features its an open source framework which give authority to run the same code at different device, we can generate several applications.Phoegap and titanium both having there features and both are good at there place.
    thanks

    ReplyDelete
  9. Increasing demand in mobile technology, boost up necessity for cross-platform mobile application. PhoneGap is the best platform for developing cross-platform apps. Innoppl is the best company for app development in San Francisco, having experience in developing cross-platform app using PhoneGap.

    ReplyDelete

  10. That's interesting! Can you please share more about it? Thank you.




    Ecommerce Web Development Company in India

    ReplyDelete
  11. Great post . It takes me almost half an hour to read the whole post. Definitely this one of the informative and useful post to me. Thanks for the share.phonegap application development in west delhi Elesoftech is a leading offshare web development,mobile application, iphone application

    ReplyDelete