Are you interested in coding mobile apps but don’t have the specialized knowledge or experience in programming and developing iOS and Android apps? Well, let me introduce you to the Ionic framework, which lets you write an app once and publish it to any mobile platform.
So, What Is Ionic?
Simply put, Ionic is a free-to-use framework that allows you to build mobile apps for iOS, Android and Windows Phone, all from one codebase. In other words, Ionic is a tool for cross-platform mobile development.
Ionic was founded in 2012 by a tech start-up called Drifty Co, and it’s now the world’s top open-source framework for building cross-platform (hybrid) mobile apps.
How Ionic Works
Ionic enables you to develop mobile apps using web technologies and languages like HTML, CSS, JavaScript, Angular, and TypeScript. Therefore, consider Ionic a front-end software development kit (SDK) for creating hybrid mobile applications. As such, Ionic provides a collection of components that mimic the native look, feel and functionality of each mobile platform. Examples of these components include buttons, tabs, menus, lists, cards, modals, and so on.
Apart from these components that provide the styling and “look and feel” for mobile apps, Ionic also provides the appropriate behaviors like navigation and gestures—for example, swiping, rotation, and pinch events, to name but a few. Ionic also includes a collection of icons called Ionicons. All these components are elements that you use in building your Ionic apps, along with Cordova and PhoneGap plugins, which we’ll touch on shortly.
How Hard Is It to Get Started?
It’s really not difficult to get started using Ionic. Ionic comes with tools to help you set up, build and run your Ionic project—this is the Ionic Command-Line Interface (CLI). All the front-end libraries and the CLI are open-source projects, so you can use them for free when developing your apps.
Why Use Ionic?
It is difficult to develop native apps. Developing Android apps alone requires you to learn how to use Android Studio’s IDE (Integrated Development Environment) and know the Java or Kotlin programming language. You’ll also need to understand Android-specific concepts like activities and intents, and you’ll create your app UIs with a custom XML syntax.
For iOS, you’d need to use the Xcode IDE (which is only available for Mac), as well as Apple’s Objective-C or Swift programming languages. Not to mention all the many Mac-specific SDKs and concepts! And on top of that, if you also decide to build for Windows Phone then you will also need to learn how to use Visual Studio’s IDE, as well as writing code in C# or Visual Basic and so on…
So, if you want to ship your app to multiple platforms, you would have to rewrite the same functionality in three different languages! Developing apps this way not only requires learning a lot of different languages and tools, it also means you end up re-coding the same logic for two or three different programming languages and mobile platforms. And the same duplication of effort is required when you need to make any changes. Developing apps natively takes a lot of time, money, and skill. So wouldn’t it be great to have a single code base that works for all three platforms?
That’s where Ionic comes in!
Hybrid Applications
Hybrid apps take advantage of each platform’s libraries or user interface components like buttons, lists, and so on. One of these components is webview—a view that displays web pages. This is a native mobile app component that can run a web application. You can therefore write an app in HTML, CSS, and JavaScript and use a webview to display it.
They are called hybrid apps because they use a mix of native code and HTML, CSS, and JavaScript. There are many frameworks that make it easy to create an app that runs a web app in a webview. The most popular is Apache Cordova, usually accessed via its most popular distribution: PhoneGap. Cordova is an open-source project, and PhoneGap, owned by Adobe, is based on Cordova and provides additional features and services on top of it.
Ionic uses the Apache Cordova project to build and run your apps as native apps.
Ionic and Cordova
Cordova acts as a bridge to native code for Ionic. It compiles your HTML, JavaScript, and CSS into native apps, enabling them to run natively on Android, iOS, and Windows Phone devices.
If you simply write a web app in the same way you would write a website and just package it as a mobile app with Cordova, the end result will be an app that looks like a website. Users will notice the style and user interaction are different from a “normal” mobile application.
That is the missing piece that Ionic provides—native look and feel. Ionic includes a collection of components that have the same look and feel as native components, using the appropriate styles and behaviors for each platform, as previously mentioned. You can therefore write your app in HTML, CSS, and JavaScript, but your app will look like a native app rather than a web page.
Cordova also provides over 200 plugins available as add-ons that you can use within your Ionic projects, which enable you to access native device APIs like the phone’s camera, geolocation, gyroscope, and so on. You can use these to enhance your app’s features and functionality.
Ionic and Angular
Chances are, you wouldn’t want to create your web apps using vanilla JavaScript, HTML, and CSS alone. Instead, you’d probably use a web framework like Angular. Angular is an incredibly popular framework that makes it easy to build reactive web applications. And now Ionic brings the power of Angular to mobile coding!
Ionic makes it possible to use the Angular framework to write mobile apps by shipping a rich library of components as well as the tooling to compile Angular TypeScript code into a bundle of vanilla JavaScript, HTML, and CSS, which Apache Cordova can then bundle into a native mobile application.
A quick diagram to illustrate the above looks something like this:
Conclusion
For anyone out there looking to get into the world of developing mobile apps, I strongly recommend and encourage you to try out Ionic, as it offers you the opportunity to develop cross-platform mobile apps, all from a single code base.
The framework is well supported and has continued to develop and grow over the years, and it continues to get better and better.
Powered by WPeMatico