-
-
Save andrewleader/673ce174d7cfc0c1235e to your computer and use it in GitHub Desktop.
code to push a live tile in Windows 10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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