Question

How will I be able to get the version number of my application in metro javascript?

For example, this is the 1.2 version of our application, how can I get the version number in my javascript metro code?

Was it helpful?

Solution

You can use the Windows.ApplicationModel.Package.current.id.version object to reference the version specified in your application manifest.

The version object contains "build, major, minor & revision" properties.

For further details, see http://msdn.microsoft.com/en-us/library/windows/apps/windows.applicationmodel.package.aspx

OTHER TIPS

Use this helper method to get the version as a complete string:

function getAppVersion() {
    var p = Windows.ApplicationModel.Package.current.id.version;
    return p.major + "." + p.minor + "." + p.build + "." + p.revision;
}

To display it to the user:

document.getElementById("version").innerHTML = "version " + getAppVersion();

This assumes you add this tag:

<span id="version"></span>

How about this;


function getCurrentApplicationVersion() {
    var currentVersion = Windows.ApplicationModel.Package.current.id.version;
    var values = [];
    for (var key in currentVersion) {
        values.push(currentVersion[key]);
    }
    return values.join('.');
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top