I develop an application with a live tile.
Why my live tile not update automatically, it's show only first (i=0) and last (i=4) then stop at last tile.
Windows.UI.Notifications.TileUpdateManager.createTileUpdaterForApplication().enableNotificationQueue(true);
getTileData();
function getTileData() {
WinJS.xhr({
url: "http://myurl",
responseType: "json"
}).then(function (xhr) {
var json = JSON.parse(xhr.responseText);
var tileArr = [];
for (var i = 0; i < 5; i++) {
var item = json[i];
tileArr.push({
"title": item.title,
"img": item.thumb_url
});
tileTitle = tileArr[i].title;
largeTileImage = tileArr[i].img;
sendTile(tileTitle, largeTileImage);
}
});
}
function sendTile(tileTitle, largeTileImage) {
var notifications = Windows.UI.Notifications;
var template = notifications.TileTemplateType.tileWideImageAndText01;
var tileXml = notifications.TileUpdateManager.getTemplateContent(template);
var tileTextAttributes = tileXml.getElementsByTagName("text");
tileTextAttributes[0].appendChild(tileXml.createTextNode(tileTitle)); // Text
var tileImageAttributes = tileXml.getElementsByTagName("image");
tileImageAttributes[0].setAttribute("src", largeTileImage); // Large image
tileImageAttributes[0].setAttribute("alt", "red graphic");
var squareTemplate = notifications.TileTemplateType.tileSquareText04;
var squareTileXml = notifications.TileUpdateManager.getTemplateContent(squareTemplate);
var squareTileTextAttributes = squareTileXml.getElementsByTagName("text");
squareTileTextAttributes[0].appendChild(squareTileXml.createTextNode(tileTitle)); // Text
var node = tileXml.importNode(squareTileXml.getElementsByTagName("binding").item(0), true);
tileXml.getElementsByTagName("visual").item(0).appendChild(node);
var tileNotification = new notifications.TileNotification(tileXml);
tileNotification.tag = "Tilebox";
notifications.TileUpdateManager.createTileUpdaterForApplication().update(tileNotification);
}
Can i use WinJS.xhr to send the data to live tile?
and what should i do?
thank you so much.