Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Note Not using JavaScript? See How to schedule a tile notification (XAML).
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.
- The ability to create a basic Windows Store app with JavaScript using Windows Runtime APIs. For more information, see Create your first Windows Store app using JavaScript.
Instructions
Step 1: 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.
var template = Windows.UI.Notifications.Tile.tileSquare150x150Text01;
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);