• Print

PhoneGap basics: What it is and what it can do for mobile developers

Joe Bowser on using PhoneGap to develop across mobile platforms.

PhoneGapPorting mobile apps across systems is, to put it kindly, an inelegant process. There’s considerable work involved — so much so that developers are sometimes forced to limit their efforts to one platform.

PhoneGap, an open-source mobile framework, offers an alternative: It helps developers build a common codebase for their apps so the apps work across devices and systems.

I recently spoke with Joe Bowser (@infil00p), creator of PhoneGap’s Android implementation, to get his take on the strengths and limitations of PhoneGap and what developers need to know before putting it to use. Bowser will dive into a number of related topics during his session at next week’s Android Open conference.

Our interview follows. (Note: this interview was conducted before Adobe announced its acquisition of PhoneGap’s parent company, Nitobi.)

What is PhoneGap and why should mobile developers consider using it?

Joe Bowser: PhoneGap is an application framework that allows developers to use HTML, JavaScript and CSS to create apps that are present as first-class applications on the phone. That means the apps have their own icons and operate similarly to native applications without a browser frame around them. They are distributed via the application stores, such as the Android Market and the Apple App Store, and they have access to a set of native functions to further make them work like native apps.

Developers use PhoneGap because it allows them to have a common codebase for all their application code. It doesn’t force developers to reinvent the wheel every time they move from platform to platform.

Are there downsides to using PhoneGap?

Joe Bowser: You are subject to the limitations of the browser and the JavaScript engine that comes with your device. On Android 2.3, this isn’t too bad. Earlier versions of Android don’t support certain features, and many of them use older JavaScript interpreters, which can impact an application. Also, there are certain things that are better implemented in native code, like cryptography or 3-D graphics. Most apps don’t use features like this — they simply display information, which the web does well.

What challenges did you face when creating the Android PhoneGap implementation?

Joe Bowser: The Android PhoneGap implementation was our first implementation after the iPhone, so there were questions about whether this was possible at all. At that time, the Android 1.0 SDK was just being released, and the only devices that ran Android were the HTC Dream and T-Mobile G1. This has obviously changed, but the most challenging thing is still testing on all the real devices that are out there. Every device has its own implementation of the Android OS and its own implementation of the WebKit rendering engine.

What’s the best way for PhoneGap developers to handle device-specific needs?

Joe Bowser: It depends on the feature set. Most applications don’t need many device-specific features beyond the user interface, but there are numerous plugins that can help with this approach. The best approach is to decide what features you need and to use only those features. There are many applications that have permissions turned on that they don’t need. For example, a simple ebook doesn’t need access to your phone state, GPS or contacts.

What is a hybrid app?

Joe Bowser: A hybrid application is one that has features of both a web application and a native application. Certain features, such as Image Capture, NFC or Android OpenAccessory, may be implemented natively since there is currently no way to do this in JavaScript. But the application logic and the UI are implemented using web technologies to allow for a consistent and unique user experience across devices.

This interview was edited and condensed.

Related:

tags: , , , , , , , , ,