Reading ionic www/config.xml file from device

…衆ロ難τιáo~ 提交于 2019-12-05 06:02:40

Take a look to the folder platforms/android and you can see that the file 'android_asset/www/config.xml' don't exists. You could try reading the file '/res/xml/config.xml' or you could try a different approach for example creating a Cordova Hook.

Cordova Hooks:

Cordova Hooks represent special scripts which could be added by application and plugin developers or even by your own build system to customize cordova commands.

You could adapt the replace text hook from this article or this build number hook based on the same hook.

UPDATE

To get only the version number of your app you could use this plugin:

Cordova AppVersion plugin

Cordova plugin to return the version number of the current app

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

Is available also with ngCordova

ngCordova has a great set of plugins when working with ionic. To get the app version use this one: http://ngcordova.com/docs/plugins/appVersion/

I wanted to display the version number in my splash screen, so I used their example and added an event:

Inside $ionicPlatform.ready callback:

$cordovaAppVersion.getVersionNumber().then(function (version) {
    $rootScope.$broadcast("appVersionResolved", { version: appVersion });
}

In the splash screen controller:

$rootScope.$on("appVersionResolved", function(event, args) {
    $scope.appVersion = args.version;
});
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!