ScheduledToastNotification.ScheduledToastNotification(XmlDocument, DateTime, TimeSpan, UInt32) constructor
Creates and initializes a new instance of a recurring ScheduledToastNotification.
Public Sub New ( content As XmlDocument, deliveryTime As DateTimeOffset, snoozeInterval As TimeSpan, maximumSnoozeCount As UInteger )
The XML that defines the toast notification content.
The date and time that Windows should first display the toast notification. You must call AddToSchedule before this time.
The amount of time between occurrences of the notification. To be valid, this value must be no less than 60 seconds and no more than 60 minutes.
The maximum number of times to display this notification. Valid values range from 1 to 5.
This type of recurring scheduled toast notification is good for a snooze alarm-like functionality. For instance, the notification could be displayed every five minutes until the maximum snooze count is reached, unless the notification is explicitly removed from the schedule in response to a user action.
Important The sender is responsible for removing the notification from the schedule once the user activates the notification through a touch or click. Failure to do so can see the notification recurring until the maximum snooze count is reached, even if the user has already dealt with it.
If you want to schedule long recurrence intervals like months or years, we recommend that you use individual scheduled toasts rather than this method. That will avoid timing errors caused by daylight savings time or leap years.
The following code shows a call to this method that displays a toast beginning at myData every five minutes for a maximum of three times.
The following example shows a toast notification scheduled to display in one hour, including the use of this constructor to create the notification, specifying a snooze interval of 60 seconds and a maximum of five times to show the notification.
var Notifications = Windows.UI.Notifications; var currentTime = new Date(); var seconds = 60; var dueTime = new Date(currentTime.getTime() + seconds * 60 * 1000); var idNumber = Math.floor(Math.random() * 100000000); // Generates a unique ID number for the notification. // Set up the notification text. var toastXml = Notifications.ToastNotificationManager.getTemplateContent(Notifications.ToastTemplateType.toastText02); var strings = toastXml.getElementsByTagName("text"); strings.appendChild(toastXml.createTextNode(This is a scheduled toast notification)); strings.appendChild(toastXml.createTextNode("Received: " + dueTime.toLocaleTimeString())); // Create the toast notification object. var toast = new Notifications.ScheduledToastNotification(toastXml, dueTime, 60 * 1000, 5); toast.id = "Toast" + idNumber; // Add to the schedule. Notifications.ToastNotificationManager.createToastNotifier().addToSchedule(toast);
Minimum supported client
Minimum supported server
|Windows Server 2012|
Minimum supported phone
|Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]|
- ScheduledToastNotification(XmlDocument, DateTime)
- Scheduled notifications sample
- Toast schema
- Guidelines and checklist for scheduled notifications