How to schedule a tile notification (XAML)

Note  Not using C#/VB/C++? See How to schedule a tile notification (HTML).

 

This topic shows how to schedule a tile notification to appear at a specific time.

What you need to know

Technologies

  • Windows Runtime

Prerequisites

Instructions

Step 1: Add namespace declarations

Windows.UI.Notifications includes the tile APIs.

using Windows.UI.Notifications;
using Windows.Data.Xml.Dom;

Step 2: Specify a template

Before you can specify the delivery time, you must create the notification.

Note  When GetTemplateContent is called on a Windows 8 system, it returns a version 1 template. When this method is called on a Windows 8.1 system, it returns a version 2 template or a version 3 template in case of phone-only templates. However, if an app specifies Windows 8 compatibility in its manifest, this method returns a version 1 template regardless of the Windows version. In this topic, we'll use a version 2 template.

 

TileTemplateType tileTemplate = TileTemplateType.TileSquare150x150Text01; 
XmlDocument tileXml = TileUpdateManager.GetTemplateContent(tileTemplate);

Step 3: Provide tile notification content

We won't cover this here because it's the same for a scheduled notification as for a non-scheduled notification. For more information, see Quickstart: Sending a tile update.

Step 4: Specify the time that the tile notification should be delivered

This example specifies that the notification should appear in 3 hours. This example uses the DateTime object.

Int16 dueTimeInHours = 3;
DateTime dueTime = DateTime.Now.AddHours(dueTimeInHours);

Step 5: Create the scheduled tile notification object

Send the tile notification content and the scheduled delivery time to the constructor.

ScheduledTileNotification scheduledTile = new ScheduledTileNotification(tileXml, dueTime);

Step 6: Optional: Give the scheduled tile notification an ID

This ID must be 16 characters or less.

scheduledTile.Id = "Future_Tile";

Step 7: Add your tile notification to the schedule.

Create the TileUpdater object, which in turn is used to add your notification to the schedule.

TileUpdateManager.createTileUpdaterForApplication().AddToSchedule(scheduledTile);

App tiles and badges sample