Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 400,000 packages pre-installed, including xenious-cordova-plugin-app-version with all npm packages installed. Try it out:

xenious-cordova-plugin-app-version lists no main file and has no index.js, so it can't be directly required. If this is a mistake, please let us know. It may however contain internal files that you can require manually:

// require("xenious-cordova-plugin-app-version/[??]")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

xenious-cordova-plugin-app-version v1.0.3

Cordova plugin to return the version number of the current app

Cordova AppVersion plugin

Reads the version of your app from the target build settings.

Installation

With cordova-cli

If you are using cordova-cli, install with:

cordova plugin add cordova-plugin-app-version

With plugman

With a plain plugman, you should be able to install with something like:

plugman --platform <ios|android> --project <directory> --plugin https://github.com/whiteoctober/cordova-plugin-app-version.git

Manually in iOS

TODO: Write these instructions

Manually in Android

TODO: Write these instructions

Use from Javascript

If you are using jQuery, AngularJS, WinJS or any Promise/A library (Bluebird), promise style is supported. Use something like:

cordova.getAppVersion.getVersionNumber().then(function (version) {
    $('.version').text(version);
});

If not, pass a callback function:

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

In addition to the version number you can also retrieve other details about your application:

getAppName

Returns the name of the app. E.g. "My Awesome App"

getPackageName

Returns the package name of the app - the reversed domain name app identifier like com.example.myawesomeapp

getVersionCode

Returns the build identifier of the app

getVersionNumber

Returns the version number of the app

Credits

Written by Robert (Jamie) Munro at White October

Various others have contributed fixes and new features. See the CHANGELOG.md for details.

Original code based on the following Stack Overflow posts:

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free