Few days ago in a blog post we learnt “How to create Schedule Task in Universal Windows apps?”. Today in this blog post we will discuss how to update live tile in an universal Windows apps. Though you don’t need to create schedule task to update live tiles but you can surely use it anytime.

Read more to learn how easy it is to configure your app to support live tile updates and integration of it with schedule task.

Users of your apps have always the demand to see a live tile notification in their screen, which enables them to see the details or most important stuffs without opening the main app. If anytime you are planning to build an app with live tile notifications, this post will help you to set it up quickly.

Here is a code snippet for you to get started, which accepts a string parameter which will be placed in your live tile:

private static void UpdateTile(string infoString) { // create the instance of Tile Updater, which enables you to change the appearance of the calling app's tile var updater = TileUpdateManager.CreateTileUpdaterForApplication(); // enables the tile to queue up to five notifications updater.EnableNotificationQueue(true); updater.Clear(); // get the XML content of one of the predefined tile templates, so that, you can customize it XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWide310x150Text04); tileXml.GetElementsByTagName("text")[0].InnerText = infoString; // Create a new tile notification. updater.Update(new TileNotification(tileXml)); }

First of all, you need to create an instance of the Tile Updater. It will enable you to change the appearance of the calling app’s tile. You can get the instance of it by calling the static method TileUpdateManager.CreateTileUpdaterForApplication().

On top of the tile updater instance, call EnableNotificationQueue method passing “true” to it as a boolean parameter. This will enable the tile to queue up to five notifications. Now call the updater.Clear() method before setting up the text into it.

Next step is to get the XML content of one of the predefined tile templates, so that, you can customize it further. Put the XML template in XmlDocument object. There are a no. of tile templates available, which you can find in the Microsoft MSDN page for “Tile Template Catalog (Windows Runtime apps)”. Choose your appropriate tile template from the list and pass it to the GetTemplateContent method (as shown above).

Next is to set the string content to the live tile template. As we are using TileWide310x150Text04 tile template type here, we are setting the “text” element found at the zero’th position.

Finally call the updater.Update(new TileNotification(tileXml)) method passing the xml template as tile notification.

In case, you want to integrate live tile update in your Windows or Windows Phone universal app/game, read my previous post “How to create Schedule Task in Universal Windows apps?”. This will help you to create the scheduler task step-by-step. Once you have the background task ready, call the above UpdateTile method from the Run method of the background task. Make sure to add the Background Tasks declaration in to your manifest and configured the project properly.

I hope the post will help you to easily configure your apps/games to have a live tile notification system with a background schedule task. In case you are facing any difficulties, drop a line below and I will try to response back as soon as possible.

Connect with me on Twitter, Facebook and Google+ to get the updates that I share over those social networking sites. Did you subscribe to my blog’s RSS feed and/or email newsletter? If not, take a moment to subscribe to it to get the immediate article notifications in your inbox.