How to schedule a tile notification (HTML)
This topic shows how to schedule a tile notification to appear at a specific time.
- Windows Runtime
- A working knowledge of tile and notification terms and concepts. For more information, see Tiles, Badges, and Notifications.
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.
var template = Windows.UI.Notifications.Tile.tileSquare150x150Text01; var tileXml = Windows.UI.Notifications.TileUpdateManager.getTemplateContent(template);
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.
var currentTime = new Date(); var startTime = new Date(currentTime.getTime() + 3 * 1000);
Send the tile notification content and the scheduled delivery time to the constructor.
var scheduledTile = new Windows.UI.Notifications.ScheduledTileNotification(tileXml, startTime);
This ID must be 16 characters or less.
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);