Plugin to get the version of PhoneGap App?

2019-04-18 22:45发布

问题:

I am using PhoneGap build to package my app is there any PhoneGap or 3rd Party Plugin that I can include in my config.xml to get the version of the app in the runtime?

Any suggestion on best way to get the version of the App would be appriciated.

回答1:

This plugin works on iOS, Windows Phone 8 and Android: http://plugreg.com/plugin/whiteoctober/cordova-plugin-app-version

If you're using the Cordova CLI, you can install via:

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

Then it's as simple as:

cordova.getAppVersion(function (version) {
    alert(version);
});

(after the device ready function has been fired)