Scheduled​Toast​Notification Scheduled​Toast​Notification Scheduled​Toast​Notification Class

Definition

Contains the XML that defines the toast notification that will display at the scheduled time.

public : sealed class ScheduledToastNotification : IScheduledToastNotification, IScheduledToastNotification2, IScheduledToastNotification3public sealed class ScheduledToastNotification : IScheduledToastNotification, IScheduledToastNotification2, IScheduledToastNotification3Public NotInheritable Class ScheduledToastNotification Implements IScheduledToastNotification, IScheduledToastNotification2, IScheduledToastNotification3
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples

The following example shows a toast notification scheduled to display in one hour.


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[0].appendChild(toastXml.createTextNode(This is a scheduled toast notification));
strings[1].appendChild(toastXml.createTextNode("Received: " + dueTime.toLocaleTimeString()));

// Create the toast notification object.
var toast = new Notifications.ScheduledToastNotification(toastXml, dueTime);
toast.id = "Toast" + idNumber;

// Add to the schedule.
Notifications.ToastNotificationManager.createToastNotifier().addToSchedule(toast);

Remarks

Create and initialize a new instance of this object by calling ScheduledToastNotification.

Constructors

ScheduledToastNotification(XmlDocument, DateTime) ScheduledToastNotification(XmlDocument, DateTime) ScheduledToastNotification(XmlDocument, DateTime)

Creates and initializes a new instance of a ScheduledToastNotification that will be displayed only once.

public : ScheduledToastNotification(XmlDocument content, DateTime deliveryTime)public ScheduledToastNotification(XmlDocument content, DateTimeOffset deliveryTime)Public Sub New(content As XmlDocument, deliveryTime As DateTimeOffset)
Parameters
content
XmlDocument XmlDocument XmlDocument

The XML that defines the toast notification content.

deliveryTime
DateTime DateTimeOffset DateTimeOffset

The date and time that Windows should display the toast notification. You must call AddToSchedule before this time.

Attributes

Examples

The following example shows a toast notification scheduled to display in one hour, including the use of this constructor to create 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[0].appendChild(toastXml.createTextNode(This is a scheduled toast notification));
strings[1].appendChild(toastXml.createTextNode("Received: " + dueTime.toLocaleTimeString()));


// Create the toast notification object.
var toast = new Notifications.ScheduledToastNotification(toastXml, dueTime);
toast.id = "Toast" + idNumber;


// Add to the schedule.
Notifications.ToastNotificationManager.createToastNotifier().addToSchedule(toast);
See Also

ScheduledToastNotification(XmlDocument, DateTime, TimeSpan, UInt32) ScheduledToastNotification(XmlDocument, DateTime, TimeSpan, UInt32) ScheduledToastNotification(XmlDocument, DateTime, TimeSpan, UInt32)

Creates and initializes a new instance of a recurring ScheduledToastNotification.

public : ScheduledToastNotification(XmlDocument content, DateTime deliveryTime, TimeSpan snoozeInterval, unsigned int maximumSnoozeCount)public ScheduledToastNotification(XmlDocument content, DateTimeOffset deliveryTime, TimeSpan snoozeInterval, UInt32 maximumSnoozeCount)Public Sub New(content As XmlDocument, deliveryTime As DateTimeOffset, snoozeInterval As TimeSpan, maximumSnoozeCount As UInt32)
Parameters
content
XmlDocument XmlDocument XmlDocument

The XML that defines the toast notification content.

deliveryTime
DateTime DateTimeOffset DateTimeOffset

The date and time that Windows should first display the toast notification. You must call AddToSchedule before this time.

snoozeInterval
TimeSpan TimeSpan TimeSpan

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.

maximumSnoozeCount
unsigned int UInt32 UInt32

The maximum number of times to display this notification. Valid values range from 1 to 5.

Attributes

Examples

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[0].appendChild(toastXml.createTextNode(This is a scheduled toast notification));
strings[1].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);

Remarks

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.

new ScheduledToastNotification(toast1, myDate, 60000, 3)
See Also

Properties

Content Content Content

Gets the XML that defines this scheduled toast notification.

public : XmlDocument Content { get; }public XmlDocument Content { get; }Public ReadOnly Property Content As XmlDocument
Value
XmlDocument XmlDocument XmlDocument

The object that contains the XML.

Attributes
See Also

DeliveryTime DeliveryTime DeliveryTime

Gets the time that this toast notification is scheduled to be displayed.

public : DateTime DeliveryTime { get; }public DateTimeOffset DeliveryTime { get; }Public ReadOnly Property DeliveryTime As DateTimeOffset
Value
DateTime DateTimeOffset DateTimeOffset

The time that this toast notification is scheduled to be displayed.

Attributes
See Also

Group Group Group

Gets or sets the group identifier for the notification.

public : PlatForm::String Group { get; set; }public string Group { get; set; }Public ReadWrite Property Group As string
Value
PlatForm::String string string

The group identifier for the notification.

Attributes

Id Id Id

Gets a developer-specified value used to identify a specific scheduled toast.

public : PlatForm::String Id { get; set; }public string Id { get; set; }Public ReadWrite Property Id As string
Value
PlatForm::String string string

The identifier. This string is limited to 16 characters.

Attributes
See Also

MaximumSnoozeCount MaximumSnoozeCount MaximumSnoozeCount

Gets the maximum number of times to display this notification.

public : unsigned short MaximumSnoozeCount { get; }public uint MaximumSnoozeCount { get; }Public ReadOnly Property MaximumSnoozeCount As uint
Value
unsigned short uint uint

The maximum number of times to display this notification. This will be a value between 1 and 5, inclusive.

Attributes

Remarks

Note that this is the number of repeat showings specified when the ScheduledToastNotification is created. It is not the number of showings remaining if the toast has already been shown. There is no method to directly retrieve that information.

See Also

NotificationMirroring NotificationMirroring NotificationMirroring

Gets or sets a value that specifies whether notification mirroring is enabled. (Notification mirroring enables a notification to appear on multiple devices.)

public : NotificationMirroring NotificationMirroring { get; set; }public NotificationMirroring NotificationMirroring { get; set; }Public ReadWrite Property NotificationMirroring As NotificationMirroring
Value
NotificationMirroring NotificationMirroring NotificationMirroring

true to enable notification mirroring; otherwise, false.

Attributes
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

RemoteId RemoteId RemoteId

Gets or sets a remote id for the notification that enables the system to correlate this notification with another one generated on another device.

public : PlatForm::String RemoteId { get; set; }public string RemoteId { get; set; }Public ReadWrite Property RemoteId As string
Value
PlatForm::String string string

A remote id for the notification that enables the system to correlate this notification with another one generated on another device.

Attributes
Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

SnoozeInterval SnoozeInterval SnoozeInterval

Gets the amount of time between occurrences of the notification.

public : IReference<TimeSpan> SnoozeInterval { get; }public Nullable<TimeSpan> SnoozeInterval { get; }Public ReadOnly Property SnoozeInterval As Nullable<TimeSpan>
Value
IReference<TimeSpan> Nullable<TimeSpan> Nullable<TimeSpan>

The time between occurrences of the notification. This value will be between 60 seconds and 60 minutes, inclusive.

Attributes

Remarks

This value is set when the ScheduledToastNotification object is created.

See Also

SuppressPopup SuppressPopup SuppressPopup

Gets or sets whether a toast's pop-up UI is displayed on the user's screen.

Do not set this property to true in a toast sent to a Windows 8.x device. Doing so will cause a compiler error or a dropped notification.

public : PlatForm::Boolean SuppressPopup { get; set; }public bool SuppressPopup { get; set; }Public ReadWrite Property SuppressPopup As bool
Value
PlatForm::Boolean bool bool

Set to true to suppress the popup message; otherwise, false. The default value is false, meaning the toast's pop-up message will be shown. Setting this property to true places the toast notification silently into the action center. This enables your app to communicate with the user without interrupting them.

Attributes

Tag Tag Tag

Gets or sets a string that uniquely identifies a toast notification inside a Group.

public : PlatForm::String Tag { get; set; }public string Tag { get; set; }Public ReadWrite Property Tag As string
Value
PlatForm::String string string

The unique identifier for this notification within a Group.

Attributes

See Also