Newer
Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Reflection;
using System.Xml.Linq;
using Windows.ApplicationModel;
using WPCordovaClassLib.Cordova;
using WPCordovaClassLib.Cordova.Commands;
namespace Cordova.Extension.Commands
{
public class AppVersion : BaseCommand
{
public void getVersionNumber(string empty)
{
string version;
if (Environment.OSVersion.Version.Major <= 8)
{
// Package.Current.Id 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
version = XDocument.Load("WMAppManifest.xml").Root.Element("App").Attribute("Version").Value;
}
else
{
version = Package.Current.Id.Version.ToString();
}
this.DispatchCommandResult(new PluginResult(PluginResult.Status.OK, version));
}
public void getAppName(string empty)
{
string name;
if (Environment.OSVersion.Version.Major <= 8)
{
//Windows.ApplicationModel.Package.Current.Id 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
name = XDocument.Load("WMAppManifest.xml").Root.Element("App").Attribute("Title").Value;
}
else
{
name = Package.Current.Id.Name;
}
this.DispatchCommandResult(new PluginResult(PluginResult.Status.OK, name));
}
public void getPackageName(string empty)
{
string package = Assembly.GetExecutingAssembly().GetName().Name;
this.DispatchCommandResult(new PluginResult(PluginResult.Status.OK, package));
}
}
}