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?
Using getVersionNumber function you can get the version.
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.
@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.
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.
@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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With