Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Periodic Live Tile Updates with Windows 8

DZone's Guide to

Periodic Live Tile Updates with Windows 8

· Mobile Zone
Free Resource

Download this comprehensive Mobile Testing Reference Guide to help prioritize which mobile devices and OSs to test against, brought to you in partnership with Sauce Labs.

One small tip if you’re creating a Windows 8 Metro app and want to update the live tile periodically using the TileUpdater-class: The request made by the OS for the live tile update doesn’t set the Content-Type so make sure that you backend is actually returning XML by default.

image

I encountered this when I built my app’s backend using ASP.NET Web Api and noticed that the live tile updates weren’t actually working. The backend was returning JSON instead of the XML because that’s the default format for the Web Api. In my case the backend only serves the live tile updates so I completely removed the JSON-formatter:

var config = new HttpSelfHostConfiguration("http://localhost:8080");
 
config.Routes.MapHttpRoute("Default", "api/{controller}/{id}",
    new { id = RouteParameter.Optional });
 
config.Formatters.RemoveAt(0);
 
using (var server = new HttpSelfHostServer(config))
{
    server.OpenAsync().Wait();
 
    Console.WriteLine("Press Enter to quit.");
    Console.ReadLine();
}

Now the backend is returning XML and the periodic live tile updates work properly.

Analysts agree that a mix of emulators/simulators and real devices are necessary to optimize your mobile app testing - learn more in this white paper, brought to you in partnership with Sauce Labs.

Topics:

Published at DZone with permission of Mikael Koskinen, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}