Skip to content

swesteme/cordova-plugin-app-version

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

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

getMetaData(propertyName)

Returns a custom property from app settings. This could be

  • a "meta-data" element from an Android manifest file
  • a custom element from an iOS Info.plist file
  • a preference value from a Windows config.xml file

Can be used in combination with cordova-custom-config plugin. Example config.xml:

...
    <platform name="android">
        <config-file target="AndroidManifest.xml" parent="./application">
           <meta-data android:name="ENVIRONMENT" android:value="DEVELOPMENT" />
        </config-file>
    </platform>
    <platform name="ios">
        <config-file platform="ios" target="*-Info.plist" parent="ENVIRONMENT"><string>DEVELOPMENT</string></config-file>
    </platform>
    <platform name="windows">
        <preference name="ENVIRONMENT" value="DEVELOPMENT" />
    </platform>
    
    <platform name="browser">
        <meta-data ENVIRONMENT="DEVELOPMENT"/>
    </platform>
...

## 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:

Update

Kevin Iuretig merged two pull requests (browser platform support + getMetaData() feature)

About

Cordova plugin to return the version number of the current app

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 54.2%
  • Objective-C 19.9%
  • Java 15.3%
  • C# 10.6%