16

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.

Hemantsom
  • 543
  • 2
  • 9
  • 24

1 Answers1

22

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)

Firze
  • 3,939
  • 6
  • 48
  • 61
Lee Crossley
  • 1,280
  • 12
  • 17
  • I am not using CLI, I use PhoneGap Build to package my App. Is there no equivalent plugin that I can add to my config.xml so that PhoneGap build can add that plugin to my package. – Hemantsom Apr 29 '14 at 09:19
  • 1
    You will have to submit a plugin to PhoneGap build (or ask someone who has written one nicely). There isn't currently a "version" plugin available: https://build.phonegap.com/plugins – Lee Crossley Apr 29 '14 at 14:31
  • @LeeCrossley Hi, I used your code, but the version stays unchnaged for iOS...in the itunes connect panel I see versions 114 (1.01), 114 (1.03), 114 (1.04) etc. And the plugin returns only '114'. Any idea ? Thanks – Louis Nov 11 '14 at 11:31
  • I would expect this to return 114 (the number in the bracket is the build I think?) Raise an issue for the plugin if you have one: https://github.com/whiteoctober/cordova-plugin-app-version/issues – Lee Crossley Nov 11 '14 at 15:26
  • @LeeCrossley just did. thanks. 114 doesn't change between builds for me. – Louis Nov 11 '14 at 21:15
  • @LeeCrossley any news on this matter? – Louis Nov 15 '14 at 09:45