How it works...

In a nutshell, the AppVersion plugin does all the heavy lifting. It's not possible for an Ionic app to find out the current version of its code using JavaScript. You may think that using local storage or cookie is an alternative, but the users could also delete that storage manually. In order to have a permanent solution, the AppVersion plugin should be used because it can read your config.xml file and get the version for you.

It's the best practice to create a separate service for all environment variables. That's why, you should have a service, called MyEnv. Also, you should inject MyEnv as a provider at the app level because you want to instantiate it only once, instead of doing it every time a new component is created. ...

Get Ionic Cookbook - Third Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.