Skip to content

Instantly share code, notes, and snippets.

@boyofgreen
Last active March 11, 2016 14:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save boyofgreen/fa11d64b3f487b46501d to your computer and use it in GitHub Desktop.
Save boyofgreen/fa11d64b3f487b46501d to your computer and use it in GitHub Desktop.
code to push a live tile in Windows 10
if (typeof Windows !== 'undefined' &&
typeof Windows.UI !== 'undefined' &&
typeof Windows.UI.Notifications !== 'undefined') {
// Construct the tile notification content
var tileContent = new Windows.Data.Xml.Dom.XmlDocument();
var tile = tileContent.createElement("tile");
tileContent.appendChild(tile);
var visual = tileContent.createElement("visual");
tile.appendChild(visual);
var bindingMedium = tileContent.createElement("binding");
bindingMedium.setAttribute("template", "TileMedium");
visual.appendChild(bindingMedium);
var peekImage = tileContent.createElement("image");
peekImage.setAttribute("placement", "peek");
peekImage.setAttribute("src", "https://unsplash.it/150/150/?random");
peekImage.setAttribute("alt", "Random demo image");
bindingMedium.appendChild(peekImage);
var text = tileContent.createElement("text");
text.setAttribute("hint-wrap", "true");
text.innerText = "Demo Message";
bindingMedium.appendChild(text);
// TODO: Add other tile size bindings, like Wide and Large
// And send the tile notification to the primary tile
var notifications = Windows.UI.Notifications;
var tileNotification = new notifications.TileNotification(tileContent);
notifications.TileUpdateManager.createTileUpdaterForApplication().update(tileNotification);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment