Learn Apache Cordova 3 Programming
- Jan 2, 2014
Each of the mobile platforms supported by Cordova has a process and tools you can use to test and, in the unlikely event your code has bugs, debug Cordova applications. In general, you can load a Cordova application into a device simulator or emulator, provided as part of the mobile platform’s SDK, or you can load an application onto a physical device. There are also third-party solutions you can use to test your Cordova applications within a desktop browser interface.
Some processes and capabilities apply across all supported mobile device platforms. In this chapter, I address the mechanics of Apache Cordova development. I begin the chapter by addressing some of the issues a Cordova developer must deal with, then cover the development process and some of the tools you can use to test and debug your Cordova applications.
Cordova Development Issues
Before we start discussing how to develop Cordova applications, let’s address some of the issues that you will face as you work with the framework. The Cordova project is supported by developers from all over the world, developers who may have experience with only one or a small number of mobile platforms, developers who have a strong opinion about how something should be done. The problem is that when you take development projects written by different people and try to collect them into a single framework, you will likely bump up against some inconsistencies. Add the fact that every mobile platform supported by Cordova is different and has different ways of doing things, and you have a difficult task to make everything work cleanly and seamlessly.
In the predecessor to this book, I used this section of the chapter to highlight all of the issues I’d encountered while learning (at the time) PhoneGap and later writing the book. Back then, there were a bunch of issues, and they created some interesting problems for developers. The good news is that over time, the Cordova development team has done an amazing job in eliminating most of them. All that’s left are two, and they’re not that complicated.
Dealing with API Inconsistency
Figure 6.1 shows the supported feature matrix from the PhoneGap website (the Cordova team doesn’t seem to publish a matrix); you can find the page at http://phonegap.com/about/feature/. As you can see, the table is pretty complete; there are some gaps, but it’s more full than empty. If a particular feature you want to use in your application is supported only on some mobile platforms, then you’ll have to make special accommodation within your application for platforms that do not support the particular API.
Figure 6.1 Cordova-Supported Feature Matrix
Each mobile platform and, often, different versions of a particular device OS have different requirements for application icons and splash screens. Developers building Cordova applications for multiple device platforms must be prepared to create a suite of graphics for their application that addresses the specific requirements for each target device platform and/or device OS. For application icons, the PhoneGap project maintains a wiki page listing the icon requirements for the different supported operating systems here: https://github.com/phonegap/phonegap/wiki/App-Icon-Sizes.
Additionally, for some devices on some carriers (older BlackBerry devices, for example), mobile carriers apply a specific theme to the OS to help distinguish themselves in the market. Any application icon designed for one of these devices will need to accommodate, as best as possible, rendering pleasantly within different themes. Fortunately, with the merges capabilities described later in this chapter, you have the ability to easily merge the appropriate graphics files (and other content as needed) into your project depending on which mobile platform you are building for.