FredLawl's Blog

Using Cordova for iOS & Android Development

| Comments

Recently I had the pleasure of writing my first mobile app. Without a background or any general knowledge of Objective-C, I had to use my skills as a JavaScript programmer to bridge the two together using a Open Sourced framework called Cordova.

Overview of Cordova

Cordova is a mobile app framework with an emphasis on cross-compability of all major mobile devices in the market. With a few vendor plugins, most of functionality that you would expect from app can be easily installed and put to use. Cordova also has extensive documentation that clearly outlines its usage and configuration. The documentation also includes notes on creating custom plugins if you can’t find any others on git that meet your criteria.

Some links to get started:

Solutions to Problems

Working with Cordova was fairly simple and straight forward. The documentation allowed me to create an app from start to finish with minimal headaches. Through the development process there were some obstacles to overcome in a short period of time.

An obstacle that was particularly hard to adjust to was the fact that the project called for a mobile-site version, and a app version of the app. Overcoming that obstacle was a challenge because links could not be treated in the same manner. When compiled, the app relies on its internal file system to load pages—where as a website would rely on its domain. The solution to this problem was simple—routing system.

The issue with routing was that the routing system could not be based on a absolute URL system. The absolute URL system would work best for a site, but not for a app due to the difference in the file systems. The solution to that was to implement a hash/push state routing system, which would allow the URLs to work not only on a hosted website, but also the app itself.

Another problem I encountered that was absolutely terrifying to deal with was external links vs internal links within the app/mobie-site. After hours of querying Google for decent solutions to the problem, I barely found a solution. The solution to the problem was to use Cordova’s InAppBrowser (which was not inherently clear—hence the hours of Google search) plugin’s'', '_system', 'location=no'); which only works for iOS and a few other devices. Android was able to utilize window.location = '';.

Part of the reason this was a difficult problem was because that Cordova used the WebViews that the different devices supplied. The WebViews could be best described as web-browsers without the browsing (hence cross-compatibility via HTML and JavaScript).


Overall Cordova was fairly fun to work with. No framework is without its quirks and there will be many more obstacles for me in the future. The whole experience really was exciting and I would recommend this framework to other developers. Here’s looking forward to future app development with Cordova!