This topic shows how to schedule a tile notification to appear at a specific time.
What you need to know
Technologies
- Windows Runtime
Prerequisites
- A working knowledge of tile and notification terms and concepts. For more information, see Tiles, Badges, and Notifications.
- Ability to create a basic Windows Store app with JavaScript using Windows Runtime APIs.
Instructions
Step 1: Specify a template
Before you can specify the delivery time, you must create the notification.
var template = Windows.UI.Notifications.Tile.tileSquareText01; var tileXml = Windows.UI.Notifications.TileUpdateManager.getTemplateContent(template);
Step 2: 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 3: Specify the time that the tile notification should be delivered
This example specifies that the notification should appear in 3 seconds. This example uses the JavaScript Date object to retrieve the current time.
var currentTime = new Date(); var startTime = new Date(currentTime.getTime() + 3 * 1000);
Step 4: Create the scheduled tile notification object
Send the tile notification content and the scheduled delivery time to the constructor.
var scheduledTile = new Windows.UI.Notifications.ScheduledTileNotification(tileXml, startTime);
Step 5: Optional: Give the scheduled tile notification an ID
This ID must be 16 characters or less.
scheduledTile.id = "Future_Tile";
Step 6: Add your tile notification to the schedule.
Create the TileUpdater object, which in turn is used to add your notification to the schedule.
var tileUpdater = Windows.UI.Notifications.TileUpdateManager.createTileUpdaterForApplication();
tileUpdater.addToSchedule(scheduledTile);
Related topics
Build date: 11/29/2012