Experiences building my first ever phone app, using Cordova and jQuery to deliver content from a WordPress installation.
I’ve been developing websites for years. Until I came to Switzerland, most of them were static HTML, although Blogger gave me my first taste of automatic publishing back at the end of the late 1990s. I started programming for content management systems in 2001 and now have loads of experience with WordPress and TYPO3.
Smartphones began changing the web browsing landscape in 2008 and since then, the tendency for consuming web content has shifted heavily towards smaller screens and consumption via mobile connections. I made my own website work with responsive design in 2010 to impress a future (now current) employer, and have produced nothing but responsive websites since then.
With the move to a much more interactive web, the need to learn how to programme applications (or “apps”) became very important. I made steps in 2011 to start thinking of how to improve interaction with a website, building on the knowledge I gained in Brienz when I worked on an online newspaper system. Stuff that any Facebook user will be familiar with: automatic previews, clicking on a button to hide a piece of information, or clicking on a button to display a hidden menu.
That all happened on the desktop and came particularly to the fore last year, when I learned more about what was possible when dynamically loading content during WordCamp in Zurich. That sowed the seed in my mind for learning more about building apps for smartphones and tablets, and increased my desire to make my own app.
And now I have. It’s not publicly available but is a simple web app which loads content via an internet connection and then stores it for offline reading. In this case, my latest blog posts via the new WordPress REST API, which is coming to Core in v4.7.
Once the content has loaded, it’s available offline; whenever the phone has an internet connection, it checks with the server every two hours to see whether there’s any new content. If there is, then it asks you if you want to load it.
The key tool I used for the app itself, with a colleague‘s help to get me up and running, is Cordova: a framework for making apps in HTML, CSS and JavaScript. Deployment happens to iOS using Xcode, and to Android via Android Studio. (Deployment, to my delight, involves a couple of simple command-line codes and then clicking on a button.)
The experience I had of making interaction work in the web browser has stood me in great stead for this first foray into the world of phone apps. Most of the interaction was, in fact, coded as a normal JavaScript application, using jQuery for a couple of tasks. I decided against frameworks like React.js or Angular.js, as they demand a whole load more learning before you can get up and running. In many cases, an experienced JavaScript developer won’t need to learn them for anything except pretty complex applications.
Coding for the web using regular JavaScript before applying mobile and offline first principles was an easy and quick way to get the app running. Then a few Cordova plugins and a couple of minor changes to things like notifications were needed, before the simple compilation and deployment. Layout and design were pretty simple, after more than five years’ intensive work on responsive websites.
I now have a hobby app to work on, and a basis for future apps which we at work can build on for fun and occasionally for our clients. We’ll never be a true competitor to other, vastly more talented app designers, but it’s fantastic (on a personal level) to have a new skill.
Leave a Reply