In a nutshell
In this post unfortunately I will not be able to tell you more exciting stuff about the card itself nor about the app reading/writing it. Instead I will provide you with some insights into the Cordova-based framework Ionic and why I recommend you to NOT use it. This may sounds quite boring but it’s also a story about the fugacity of software frameworks and peppered with quite a number of useful links.
Why I tried using Ionic
The main reason for me to do this project is to acquire all necessary skills to quickly prototype an Android app.
It happened a couple of times already that I had a very nice idea or even a more or less elaborate roadmap to a product but in the end decided to file it away due to the gigantic overhead of app development. I really dislike doing this. It feels like throwing away so much potential while heading towards a future where one is employed in a faceless company programming/calculating some redundant and useless stuff. I know this is a way to bleak picture but you get the point: One would miss a lot of fun.
When you scroll down the web page of Cordova you see a list of all the different frameworks building on top of it, like Ionic, Monaca, Onsen UI and Taco. After reviewing their capabilities, licenses and user bases I decided to go for Ionic. Ionic offers the following advantages over Cordova:
- It provides a large number of HTML components allowing the user to have a native feeling she knows from other Android applications out of the box.
- Its developer tools are more advanced. Instead of building and running your app every single time, you can deploy it in your browser or smartphone using
ionic serveand whenever you save a change to any of its source files the app is going to be recompiled and reloaded. Just like you know from nodeJS. (Ionic is itself a npm package)
Why I failed
Already at this first steps I noticed something unsettling: most of the advises that can be found on StackOverflow etc. do not work anymore. Ionic had an upgrade to Ionic2 in 2016 which is now not based on AngularJS anymore but instead on Angular2. While this is said to be a benefit for all developers it inevitably breaks all the code of the previous version. So in the end I felt like an early adapter in a language I am not familiar with. Hmmm.
A feature I was quite excited about was the possibility to use databases within the app. After all big data is a buzzword which should appear in every application nowadays.
According to the Cordova documentation there are four ways to store your data (persistently):
– localStorage which is quite easy to handle but limited to key-value pairs only.
– WebSQL which was the SQL implementation in browsers but is now deprecated.
– IndexDB which is recommended by the Cordova community. In addition it is also well documented. Be sure to check out the IndexDB documentation for all kind of information regarding non-SQL databases. It’s quite well written.
– Additional plugins like SQLite
Worth mentioning you can also use localForage which is some sort of frontend using the first three ways of Cordova’s storage capabilities, Angular-based wrappers like Angular-cache (which doesn’t seem to be developed anymore) and ngStorage and databases-as-a-service like Firebase or Backand.
I decided to work with IndexDB but after some search in the web I had to realize that there is neither an example nor an explanation how to use it with Ionic2. Instead to most recent versions of blog posts and Youtube videos all rely on the SQLite plugin of Cordova.
But when I these tried all this code I failed.
After some sleepless nights I found the problem to be not my inferior programming skills but the developers of Ionic2 who again broke the existing code. They moved the modules responsible for storing data and broke all apps relying on them. Also the interface for accessing databases changed. Apparently.
Most probably one can still access databases but I have no idea how. There are some snippets of code and information around but no working example. And without any context this is not of much help for noobs like me.
It is one thing to make an upgrade of you language/framework and to break the code of the previous version. But it’s a completely different thing to break the user’s code twice a year. This is just too much.
As a conclusion I can just recommend to NOT use Ionic2 unless you are already familiar with coding in Angular2 and TypeScript as well as with the peculiarities of Cordova. In addition even the example application need a lot of time for startup.
What will happen next
For my next projects I will not use Cordova again but instead will develop apps in plain Java. In the beginning I thought there will be less overhead and an easier development. But even without the direct comparison to Java I can conclude that this was definitely not the case. It’s a fast developing framework not much people are using. In addition you have to have a Mac to deploy your apps on iOS and it’s way slower than a native application.
For this series I will nevertheless stick to Cordova and will build an application to read and write the Mensacards content for the third part. However there won’t be the possibility of storing the cards inside the application and building a database of them.