Ensuring that users of your app are on latest version is critically important. I have seen users reporting issues and requesting features which were implemented a few updates ago. With Windows Phone 8.1, users can enable automatic app updates installation but for users who are still on Windows 8 or who do not enable automatic updates, the responsibility is on you, as a developer.
Unfortunately, there is no support in Windows Phone SDK to find out if there is a new version of the current app in store or what version is available in store. For the converge app, I was looking to solve this issue so I traced store app’s network traffic using Fiddler to understand the available APIs. Looking at the network traffic, the API used by store app is fairly obvious. Here is the API request Windows Phone 8 store app sends for app details.
GET http://marketplaceedgeservice.windowsphone.com/v8/catalog/apps/b658425e-ba4c-4478-9af3-791fd0f1abfe?os=8.0.10521.0&cc=US&lang=en-US&hw=520208901&dm=RM-940_nam_att_200&oemId=NOKIA&moId=att-us&cf=99-1 Accept: */* Accept-Encoding: gzip User-Agent: ZDM/4.0; Windows Mobile 8.0 X-WP-Client-Config-Version: 107 X-WP-MO-Config-Version: 1224 X-WP-Device-ID: **** X-WP-ImpressionId: ****:API.BDIGeneric X-WP-ImpressionK: 5
You don’t need to send all headers or parameters in requests. The response to this call has complete details for your application in the target country/language in xml format. From here on, you can use LINQ to XML to get the data you need to know what version is available in store. Here is slightly modified version of the code I use in the converge app. Feel free to reuse.
//This code has dependency on Microsoft.Net.Http NuGet package. public async Task CheckUpdate() { const string storeAppDetailsUri = "http://marketplaceedgeservice.windowsphone.com/v8/catalog/apps/b658425e-ba4c-4478-9af3-791fd0f1abfe?os={0}&cc={1}&lang={2}"; var updatedAvailable = false; try { var osVersion = Environment.OSVersion.Version.ToString(4); var lang = CultureInfo.CurrentCulture.Name; var countryCode = lang.Length == 5 ? lang.Substring(3) : "US"; using (var message = new HttpRequestMessage(HttpMethod.Get, string.Format(storeAppDetailsUri, osVersion, countryCode, lang))) { message.Headers.Add("User-Agent", "Windows Mobile 8.0"); using (var client = new HttpClient()) { var response = await client.SendAsync(message); if (response.StatusCode != HttpStatusCode.OK) return; using (var stream = await response.Content.ReadAsStreamAsync()) { XNamespace atom = "http://www.w3.org/2005/Atom"; XNamespace apps = "http://schemas.zune.net/catalog/apps/2008/02"; var doc = XDocument.Load(stream); if (doc.Document == null) return; var entry = doc.Document.Descendants(atom + "feed") .Descendants(atom + "entry") .FirstOrDefault(); if (entry == null) return; var versionElement = entry.Elements(apps + "version").FirstOrDefault(); if (versionElement == null) return; Version storeVersion; if (Version.TryParse(versionElement.Value, out storeVersion)) { var currentVersion = new AssemblyName(Assembly.GetExecutingAssembly().FullName).Version; updatedAvailable = storeVersion > currentVersion; } } } } } catch (Exception ex) { // HANDLE ERROR HERE. THERE IS NO POINT IN SHOWING USER A MESSAGE. GOOD PLACE TO SEND SILENT ERROR REPORT OR JUST SWALLOW THE EXCEPTION. Debug.WriteLine(ex); } if (updatedAvailable) { // APP UPDATE IS AVAILABLE. SHOW FIREWORKS IN APP OR JUST OPEN STORE APP TO UPDATE THE APP AFTER USER'S CONSENT. } }
This is definitely not a documented and supported API but considering there are millions of devices using this API, I doubt this will break in foreseeable future. I just don’t understand why Windows Phone team doesn’t make this API public and have folks build stuff on top of it. They have struggled to produce a good store experience since Windows Phone launched anyways. For Windows 8, the APIs are as useless as the store app is so don’t bother trying to do something similar there.
A side note: regardless of how good you think the updates are, don’t update the app too frequently (multiple times in a week) if you have this notification implemented in the app. This becomes annoying and users start reporting it in reviews. This happened when I had to release multiple updates in a week to resolve content infringement complaints submitted by The Verge.
Hope this help.