Many of times you find crashes in your application and you feel that you
should prepare an update for the application. After you have prepared an update
for your application you upload it and it is notified of your store. Wouldn't it
be great to notify the user that an update for this very application is
available.
When your phone searches for update, it goes to the following link.
- http://marketplaceedgeservice.windowsphone.com/v8/catalog/apps/<application id>?os=8.0.9903.0&cc=GB&oc=&lang=en-GB&hw=520170499&dm=RM-821_eu_euro1&oemId=NOKIA&moId=VOD-GB&cf=99-1
Now how we can do this all stuff in our application?
Well that is not much difficult all you have to do is just write a piece of code.
For checking that is the application's update is available over store or not you need to get the ProductID of your application here is link below from where you can get your ProductID &Read WMAppManifest.xml.
For the current running application you need to read its WMAppManifest.xml file.
Code is below:
- public static string GetManifestAttributeValue(string attributeName)
- {
- var xmlReaderSettings = new XmlReaderSettings
- {
- XmlResolver = new XmlXapResolver()
- };
- using (var xmlReader = XmlReader.Create("WMAppManifest.xml", xmlReaderSettings))
- {
- xmlReader.ReadToDescendant("App");
- return xmlReader.GetAttribute(attributeName);
- }
- }
- private Task<Version> GetUpdatedVersion()
- {
- var cultureInfoName = CultureInfo.CurrentUICulture.Name;
- var url = string.Format("http://marketplaceedgeservice.windowsphone.com/v8/catalog/apps/{0}?os={1}&cc={2}&oc=&lang={3}",
- GetManifestAttributeValue("ProductID"),
- Environment.OSVersion.Version,
- cultureInfoName.Substring(cultureInfoName.Length - 2).ToUpperInvariant(),
- cultureInfoName);
- var request = WebRequest.Create(url);
- return Task.Factory.FromAsync(request.BeginGetResponse, result =>
- {
- var response = (HttpWebResponse)request.EndGetResponse(result);
- if (response.StatusCode != HttpStatusCode.OK)
- {
- throw new WebException("Http Error: " + response.StatusCode);
- }
- using (var outputStream = response.GetResponseStream())
- {
- using (var reader = XmlReader.Create(outputStream))
- {
- reader.MoveToContent();
- var aNamespace = reader.LookupNamespace("a");
- reader.ReadToFollowing("entry", aNamespace);
- reader.ReadToDescendant("version");
- return new Version(reader.ReadElementContentAsString());
- }
- }
- }, null);
- }
Here you go,
- private async void CheckForUpdatedVersion()
- {
- var currentVersion = new Version(GetManifestAttributeValue("Version"));
- var updatedVersion = await GetUpdatedVersion();
- if (updatedVersion > currentVersion
- && MessageBox.Show("Do you want to install the new version now?", "Update Available", MessageBoxButton.OKCancel) == MessageBoxResult.OK)
- {
- new MarketplaceDetailTask().Show();
- }
- }
CheckForUpdatedVersion() in your application and use it.
Reference: Checking for updates from inside a Windows Phone app.
Personal Blog: Blend Unleashed.

Imran Javed ZiaPosted Dec 5, 2015, 6:41 AM
Nice work