Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display version on screen from config.xml in Ionic2

Tags:

ionic2

We are developing an app which has a screen named "About Us" where we want to display the app's version number which is same as in config.xml file.

<widget id="com.myApp.MyAppName" version="2.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">

Is there any way to copy the version no from the mentioned xml file to my screen's ts file or vice-versa?

like image 670
Nikhil Avatar asked May 04 '17 07:05

Nikhil


People also ask

How do I show app version in Ionic?

Using getVersionNumber function you can get the version.

How do I change my version of Ionic?

For ionic 4, there is no android-versionCode field. So you should change the version in widget field (usually line 2) in the config. xml file. In this case, just change the version from 0.0.

Why does ionic have 4 spaces in config XML?

@uloco The Ionic CLI rewrites config.xml to have 4 spaces because that's exactly what the Cordova CLI does as well. If you have a hook in after_prepare, it will run after the Cordova prepare step, which happens in the middle of ionic cordova run.

How to override the initial ionic config for the app?

To override the initial Ionic config for the app, provide a config in IonicModule.forRoot in the app.module.ts file. ... ... In the above example, we are disabling the Material Design ripple effect across the app, as well as forcing the mode to be Material Design.

Is there a way to prevent config XML rewrite in ionic V3?

@mburger81 With the new release of Ionic v3 we will no longer be modifying the package.json file. Also the config.xml rewrite will only occur only with 'ionic cordova run' or 'ionic cordova emulate'. That being said I second the comment by @dwieeb there isn't a good way to prevent the rewrite of config.xml.

Where are ionic configuration files stored?

Configuration values are stored in JSON files. The Ionic CLI maintains a global configuration file, usually located at ~/.ionic/config.json, and project configuration files, usually at the project's root directory as ionic.config.json.


1 Answers

Check this plugin out: http://ionicframework.com/docs/native/app-version/

Github link : https://github.com/whiteoctober/cordova-plugin-app-version

Let me know if this work out for you. Can help with specifics if needed.

like image 60
Sagar Kulkarni Avatar answered Sep 30 '22 18:09

Sagar Kulkarni