Search code examples
javascriptwindowswindows-8windows-phonelive-tile

How to Populate a Windows 8.1 live tile?


I'm following the documentation here http://msdn.microsoft.com/en-us/library/windows/apps/hh465429.aspx, and I have managed to create a live tile for my app.

However the documentation does not say how to populate the live tile with content, and I'm not sure how to do this. My code is here

Windows.UI.Notifications.TileUpdateManager.createTileUpdaterForApplication().enableNotificationQueue(true);

var template = Windows.UI.Notifications.TileTemplateType.tileWide310x150Text04;

var tileXml = Windows.UI.Notifications.TileUpdateManager.getTemplateContent(template);

// TO DO: Fill in the template with your tile content. Define a tile and add it to tileXML.

var tileNotification = new Windows.UI.Notifications.TileNotification(tileXml);

Windows.UI.Notifications.TileUpdateManager.createTileUpdaterForApplication().update(tileNotification);

Solution

  • The Sending a tile update documentation walks you through adding content to the tile. After calling getTileContent as you have done above, you can update the xml like such

    var tileTextAttributes = tileXml.getElementsByTagName("text");
    tileTextAttributes[0].appendChild(tileXml.createTextNode("Hello World! My very own tile notification"));
    

    There are many more examples in that doc