Skip to content

Instantly share code, notes, and snippets.

@seksenov
Last active October 16, 2016 12:33
Show Gist options
  • Save seksenov/5270d534fad70e98054b to your computer and use it in GitHub Desktop.
Save seksenov/5270d534fad70e98054b to your computer and use it in GitHub Desktop.
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