Apache Cordova

I’ve recently been playing around with Apache Cordova (formerly PhoneGap) and I love it.  It’s an incredibly easy way to get a mobile project up and running.  In my particular case, I care about having access to some basic phone APIs and leveraging a remote server for the guts of the app itself.  Apache Cordova lets you use HTML, CSS, and JavaScript to make mobile apps that can be deployed to iOS, Android, and whatever other platforms you might care about – write once, deploy anywhere (where have I heard that before?).  There are also some pretty cool plugins that work with the framework for doing things like barcode scanning as an example.

The code below is javascript that scans a barcode and opens a URL with the value using a browser window in the app (that looks like its part of the app).  This lets me write most of my app logic in a server based web app, and for my purposes, minimize the mobile app aspect of things.

doSomething: function(){
        cordova.plugins.barcodeScanner.scan(
          function (result) {
            var res = result;
              navigator.geolocation.getCurrentPosition(
                function (position){
                   if (res.text!=''){
                    var ref = window.open('http://mysecretapp.com/establishments/' + res.text + '/wouldntyouliketoknow/new?lat=' + position.coords.latitude + '&lon=' + position.coords.longitude , '_blank', 'location=no');
                   }
                }, this.onError);
          },
          function (error) {
              alert("Scanning failed: " + error);
          }
        );
    },
    onError: function(error){
        alert('code: ' + error.code + '\n' +
              'message: ' + error.message + '\n');
    },
Its a fair question to ask why I would want to write an app this way, maybe I’ll address that in a future post, but suffice it to say, this provides the advantage of the distribution channels afforded to mobile apps (app stores), without needing to produce an API for the server component.  Main drawback is the user has to be connected and have Internet access, but again, this is a fine use case for what we’re developing.
Advertisements

Jason is an technical business professional who has deep hands-on technical experience as a software engineer and architect and has leveraged this experience to transition from project leadership into product management. He holds a MS in Computer Science from Northeastern University and an MBA from Babson College. He is continuously striving to learn and experience new challenges.

Posted in Software Development

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: