Metro App version info programmatically
Asked Answered
G

3

7

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?

Grace answered 19/2, 2012 at 23:50 Comment(0)
F
9

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

Firecracker answered 20/2, 2012 at 3:7 Comment(0)
C
11

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>
Chug answered 22/2, 2012 at 1:30 Comment(0)
F
9

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

Firecracker answered 20/2, 2012 at 3:7 Comment(0)
M
0

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('.');
}
Minx answered 14/12, 2012 at 15:48 Comment(1)
You're making assumptions about the iteration order of Object Keys in JavaScript. See: https://mcmap.net/q/37115/-elements-order-in-a-quot-for-in-quot-loopPursuant

© 2022 - 2024 — McMap. All rights reserved.