summaryrefslogtreecommitdiff
path: root/plugins/uk.co.whiteoctober.cordova.appversion/src/wp8/AppVersion.cs
blob: 2f3d2c95da425b6ce447eab67b23636417206d43 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System;
using System.Windows;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using WPCordovaClassLib.Cordova;
using WPCordovaClassLib.Cordova.Commands;
using WPCordovaClassLib.Cordova.JSON;
using Windows.ApplicationModel;
using System.Xml.Linq;

namespace Cordova.Extension.Commands
{
    public class AppVersion : BaseCommand
    {
        public void getVersionNumber(string empty)
        {
            //Windows.ApplicationModel.Package.current.id.version is NOT working in Windows Phone 8
            //Workaround based on http://stackoverflow.com/questions/14371275/how-can-i-get-my-windows-store-apps-title-and-version-info
            String version= XDocument.Load("WMAppManifest.xml").Root.Element("App").Attribute("Version").Value;

            this.DispatchCommandResult(new PluginResult(PluginResult.Status.OK, version));
        }
    }
}