Last active
October 16, 2016 12:33
-
-
Save seksenov/5270d534fad70e98054b to your computer and use it in GitHub Desktop.
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
function updateTile(message, imgUrl, imgAlt) { | |
// Namespace: Windows.UI.Notifications | |
if (typeof Windows !== 'undefined'&& | |
typeof Windows.UI !== 'undefined' && | |
typeof Windows.UI.Notifications !== 'undefined') { | |
var notifications = Windows.UI.Notifications, | |
tile = notifications.TileTemplateType.tileSquare150x150PeekImageAndText01, | |
tileContent = notifications.TileUpdateManager.getTemplateContent(tile), | |
tileText = tileContent.getElementsByTagName('text'), | |
tileImage = tileContent.getElementsByTagName('image'); | |
tileText[0].appendChild(tileContent.createTextNode(message || 'Demo Message')); | |
tileImage[0].setAttribute('src', imgUrl || 'https://unsplash.it/150/150/?random'); | |
tileImage[0].setAttribute('alt', imgAlt || 'Random demo image'); | |
var tileNotification = new notifications.TileNotification(tileContent); | |
var currentTime = new Date(); | |
tileNotification.expirationTime = new Date(currentTime.getTime() + 600 * 1000); | |
notifications.TileUpdateManager.createTileUpdaterForApplication().update(tileNotification); | |
} else { | |
//Alternative behavior | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment