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
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.