Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the version string I defined in the config.xml

Tags:

How do I find out, which version my Cordova app is? I need that information to display it in an About screen.

Is it possible to read the config.xml and get the version string, which i am already maintaining in this file?

<widget ... version="0.0.1" ... 

I would like to have a solution where I do not have to maintain the app's version number in several places in the code. Also, I do not want a plugin for that purpose, because most plugins do not support Android, iOS and browser as platforms.

Or am I overlooking a core plugin attribute?

Or is there a solution where I maintain one file, which is no the config.xml, and the config.xml gets the version information from that file?

How are you implementing "display version info" in your app's about screen? Any hint is appreciated.

My Cordova version is:

>cordova -v 4.2.0 
like image 314
Strubbl Avatar asked Feb 03 '15 16:02

Strubbl


People also ask

What is config XML in ionic?

config. xml is a global configuration file that controls many aspects of a cordova application's behavior. This platform-agnostic XML file is arranged based on the W3C's Packaged Web Apps (Widgets) specification, and extended to specify core Cordova API features, plugins, and platform-specific settings.

What is config XML file?

The config. xml file is a persistent store for the managed objects that WebLogic Server creates and modifies during its executing using the BEA implementation of the JMX API. The purpose of config. xml is to store changes to managed objects so that they are available when WebLogic Server is restarted.


1 Answers

If you are not interested in using any third party plugin to achieve this, then I feel Cordova hooks is the way to go. You can come up with a before_build hook to read the version from config.xml file and make use of the same in app.

Fortunately, this hook is readily available for you in the following link where they are reading version from config.xml and injecting it as a dependency wherever required.

Suggest you to also have a look at the official documentation of cordova hooks for better understanding.

In fact, you can also try out reading version info from config.xml and directly put it in some placeholder that you can create in your index.html to display the version info. This can be done before cordova build using hooks which in turn uses windows batch file that does the file operations. You can checkout a working sample of cordova hook that uses batch file in my github page.

like image 84
Gandhi Avatar answered Oct 10 '22 16:10

Gandhi