Tuesday 12 December 2017

18 months?!

Someone at work this week commented that my blog was not exactly up to date and they weren't wrong.

I have spent a lot of the last 18 months helping my wife with her business (http://www.leaveyouregosatthedoor.com/) albeit it in a IT capacity rather than anything else. As well as what seems like a multitude of websites some of this time has been spent building a mobile app for her.

I always tended to write things from scratch when coding on RISC OS but these days the wealth of freely available tools and libraries means there are no good reasons for doing this and nowadays I tend to look for shortcuts.

When I approached writing a mobile app I naturally gravitated towards Android as this is my mobile platform of choice. Big problem. My wife loves her iPhone. I really didn't have the time to natively code an Android and iOS app and these days I find my brain is getting a bit too full to be learning new technologies at the pace I used to be able to.

Hybrid development

I had previously encountered a cross platform mobile framework called Cordova created by Apache and a variant of it called PhoneGap packaged by Adobe. It was fairly obvious that if I want to write a highly performant app then this might not be the way to go, but I didn't need that so I thought I'd give it a go.

This framework allows you to code in HTML, CSS and JS (I prefer jQuery, but most modern web frameworks would have been fine). It also provides a way to access the native capabilities of the phone such as camera, location services and storage via a healthy range of plugins.

User interface

One thing I wanted that wasn't provided was an easy way to support the native look and feel of the target device. Sure I could build my own CSS to do this, but that would be tedious and time consuming. I settled upon the Onsen UI framework to take care of this for me. This will give a iOS or Android skin depending on the device on which it is running.


The app has some requirements to be able to store class and course information on the phone so they can be viewed when offline. When I started I used the local SQL capabilities of the phone and kept it up to date using remote web service calls when online.

This worked OK, but updating the schema of the database was tedious and error prone and keeping the data in sync was a little clunky.


I was already using  Firebase to send push notifications to the phone and for crash reporting via some of the aforementioned Cordova plugins. I then investigated their Firestore offering.

This is pretty clever stuff. You register a listener against a database on the device with is automatically synced to the version in the cloud without you needing to do anything. Change something in the cloud and it syncs to the device, fires an event and you can refresh the page. No connection? No problem. It transparently handles the synchronisation when you next get one.

And it's fast. Make a change to the database in a web browser and almost instantaneously the update is pushed to the phone.

Only one problem. No Cordova plugin. Maybe it was time I did make the effort to learn a bit of new technology. Writing the Android version was OK - I code in Java at work and there were some good existing plugins to learn from.

iOS was less fun. I consider my C and C++ to be reasonable if maybe a little rusty. How difficult could Objective C be? Oh, and the lack of a Mac to run the XCode IDE on....

The Mac problem was resolved using VirtualBox surprisingly easily - and I have to say I am very impressed how well MacOS runs in a fairly small VM. Much more performant than Linux or Windows on the same spec.

Objective C? Well once you get used to it, it isn't that bad...

End result

So although it will continue to evolve, the app is live on Google Play and I hope at some point soon on the App Store.

The Cordova plugin is available on github and via  npm.

What seemed a relatively simple undertaking did end up causing me to learn a lot of new things but also enabled me to give back a little to open source community via the Cordova plugin.

I'm just glad I didn't decide to try and do it all myself!

The cover page
List of available classes
Class specific details
Guide to some poses

No comments:

Post a Comment