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 review their capabilities, licenses, and user base 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 of any of its source files, the app is going to be recompiled and reloaded. Just like you know from nodejs. (Ionic itself is a node package)
Why I failed.
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 documentation of Cordova 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 is 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 Ionic. Instead to most recent versions of blog posts and YouTube videos all rely on the SQLite plugin of Cordova.
But regardless which these I tried, 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. Without any context, this is not of that 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 to break the code twice a year is just to 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 used by only a few people. 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 in the third part. The Ionic version, however, I will definitely drop.