Update all tile sizes in WIndows 8 app with periodic notification

1k Views Asked by At

I have an application framework (in JavaScript) which dynamically sets the URLs for the live tile feed. In my code I have something like below, and this works for a wide tile, but when I resize the tile to "medium" (or "small") the live feed/update is gone. If I resize back to wide it works just fine. There is no other tile setup (it uses the default).

My question is: is there anyway to update all tile sizes at the same time, or will I have to build a full XML object using getTemplateContent() and the TileUpdater's update() method?

I currently update the periodic URLs like so (again, this works for wide tiles):

var updater = Windows.UI.Notifications.TileUpdateManager.createTileUpdaterForApplication();
updater.clear();
updater.stopPeriodicUpdate();
updater.enableNotificationQueue(true);
updater.startPeriodicUpdateBatch(
    [ new Windows.Foundation.Uri(feedUrlString) ],
    Windows.UI.Notifications.PeriodicUpdateRecurrence.halfHour
);
1

There are 1 best solutions below

4
On

To update multiple tile sizes in a single update, the XML payload for that update must contain individual elements for each tile size.

You can see this in the App tiles and badges sample in the SDK. Scenario 1, for instance, demonstrates how to do this using (a) the C# NotificationExtensions library, (b) building the XML as a string, and (c) using getTemplateContent. One of these methods should work for you.

To give an example for case (a), here's the code from scenario 1 that also has a comment explaining more:

// This sample application supports all four tile sizes – small (Square70x70), medium (Square150x150), wide (Wide310x150) and large (Square310x310).
// This means that the user may have resized their tile to any of these four sizes for their custom Start screen layout.
// Because an app has no way of knowing what size the user resized their app tile to, an app should include template bindings
// for each supported tile sizes in their notifications. The only exception is the small (Square70x70) tile size because this size
// does not support live tile notifications, which is why there are no Square70x70 tile templates.
// We assemble one notification with three template bindings by including the content for each smaller
// tile in the next size up. Square310x310 includes Wide310x150, which includes Square150x150.
// If we leave off the content for a tile size which the application supports, the user will not see the
// notification if the tile is set to that size.

// Create a notification for the Square310x310 tile using one of the available templates for the size.
var tileContent = NotificationsExtensions.TileContent.TileContentFactory.createTileSquare310x310Text09();
tileContent.textHeadingWrap.text = "Hello World! My very own tile notification";

// Create a notification for the Wide310x150 tile using one of the available templates for the size.
var wide310x150Content = NotificationsExtensions.TileContent.TileContentFactory.createTileWide310x150Text03();
wide310x150Content.textHeadingWrap.text = "Hello World! My very own tile notification";

// Create a notification for the Square150x150 tile using one of the available templates for the size.
var square150x150Content = NotificationsExtensions.TileContent.TileContentFactory.createTileSquare150x150Text04();
square150x150Content.textBodyWrap.text = "Hello World! My very own tile notification";

// Attach the Square150x150 template to the Wide310x150 template.
wide310x150Content.square150x150Content = square150x150Content;

// Attach the Wide310x150 template to the Square310x310 template.
tileContent.wide310x150Content = wide310x150Content;

// Send the notification to the application’s tile.
Windows.UI.Notifications.TileUpdateManager.createTileUpdaterForApplication().update(tileContent.createNotification());