ScheduledToastNotification ScheduledToastNotification ScheduledToastNotification ScheduledToastNotification Class

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

Syntax

Declaration

public sealed class ScheduledToastNotificationpublic sealed class ScheduledToastNotificationPublic NotInheritable Class ScheduledToastNotification

Remarks

Create and initialize a new instance of this object by calling @Windows.UI.Notifications.ScheduledToastNotification.#ctor(Windows.Data.Xml.Dom.XmlDocument,Windows.Foundation.DateTime,Windows.Foundation.TimeSpan,System.UInt32).

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);

Constructors summary

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

Creates and initializes a new instance of a recurring ScheduledToastNotification.

Properties summary

Gets the XML that defines this scheduled toast notification.

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

Gets or sets the group identifier for the notification.

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

Gets the maximum number of times to display this notification.

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

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

Gets the amount of time between occurrences of the notification.

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.

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

Constructors

  • ScheduledToastNotification(Windows.Data.Xml.Dom.XmlDocument,Windows.Foundation.DateTime)
    ScheduledToastNotification(Windows.Data.Xml.Dom.XmlDocument,Windows.Foundation.DateTime)
    ScheduledToastNotification(Windows.Data.Xml.Dom.XmlDocument,Windows.Foundation.DateTime)
    ScheduledToastNotification(Windows.Data.Xml.Dom.XmlDocument,Windows.Foundation.DateTime)

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

    public ScheduledToastNotification(Windows.Data.Xml.Dom.XmlDocument content,Windows.Foundation.DateTime deliveryTime)public ScheduledToastNotification(Windows.Data.Xml.Dom.XmlDocument content,Windows.Foundation.DateTime deliveryTime)Public Function ScheduledToastNotification(content As Windows.Data.Xml.Dom.XmlDocument,deliveryTime As Windows.Foundation.DateTime) As

    Parameters

    Remarks

    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);
    
  • ScheduledToastNotification(Windows.Data.Xml.Dom.XmlDocument,Windows.Foundation.DateTime,Windows.Foundation.TimeSpan,System.UInt32)
    ScheduledToastNotification(Windows.Data.Xml.Dom.XmlDocument,Windows.Foundation.DateTime,Windows.Foundation.TimeSpan,System.UInt32)
    ScheduledToastNotification(Windows.Data.Xml.Dom.XmlDocument,Windows.Foundation.DateTime,Windows.Foundation.TimeSpan,System.UInt32)
    ScheduledToastNotification(Windows.Data.Xml.Dom.XmlDocument,Windows.Foundation.DateTime,Windows.Foundation.TimeSpan,System.UInt32)

    Creates and initializes a new instance of a recurring ScheduledToastNotification.

    public ScheduledToastNotification(Windows.Data.Xml.Dom.XmlDocument content,Windows.Foundation.DateTime deliveryTime,Windows.Foundation.TimeSpan snoozeInterval,System.UInt32 maximumSnoozeCount)public ScheduledToastNotification(Windows.Data.Xml.Dom.XmlDocument content,Windows.Foundation.DateTime deliveryTime,Windows.Foundation.TimeSpan snoozeInterval,System.UInt32 maximumSnoozeCount)Public Function ScheduledToastNotification(content As Windows.Data.Xml.Dom.XmlDocument,deliveryTime As Windows.Foundation.DateTime,snoozeInterval As Windows.Foundation.TimeSpan,maximumSnoozeCount As System.UInt32) As

    Parameters

    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)
    

    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);
    

Properties

  • Content
    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

    Property Value

  • DeliveryTime
    DeliveryTime
    DeliveryTime
    DeliveryTime

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

    public DateTime DeliveryTime { get; }public DateTime DeliveryTime { get; }Public ReadOnly Property DeliveryTime As DateTime

    Property Value

  • Group
    Group
    Group
    Group

    Gets or sets the group identifier for the notification.

    public string Group { get; set; }public string Group { get; set; }Public ReadWrite Property Group As string

    Property Value

    • string
      string
      string
      string

      The group identifier for the notification.

  • Id
    Id
    Id
    Id

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

    public string Id { get; set; }public string Id { get; set; }Public ReadWrite Property Id As string

    Property Value

    • string
      string
      string
      string

      The identifier. This string is limited to 16 characters.

  • MaximumSnoozeCount
    MaximumSnoozeCount
    MaximumSnoozeCount
    MaximumSnoozeCount

    Gets the maximum number of times to display this notification.

    public uint MaximumSnoozeCount { get; }public uint MaximumSnoozeCount { get; }Public ReadOnly Property MaximumSnoozeCount As uint

    Property Value

    • uint
      uint
      uint
      uint

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

    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.

  • NotificationMirroring
    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

    Property Value

  • RemoteId
    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 string RemoteId { get; set; }public string RemoteId { get; set; }Public ReadWrite Property RemoteId As string

    Property Value

    • string
      string
      string
      string

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

  • SnoozeInterval
    SnoozeInterval
    SnoozeInterval
    SnoozeInterval

    Gets the amount of time between occurrences of the notification.

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

    Property Value

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

    Remarks

    This value is set when the ScheduledToastNotification object is created.

  • SuppressPopup
    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 bool SuppressPopup { get; set; }public bool SuppressPopup { get; set; }Public ReadWrite Property SuppressPopup As bool

    Property Value

    • bool
      bool
      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.

  • Tag
    Tag
    Tag
    Tag

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

    public string Tag { get; set; }public string Tag { get; set; }Public ReadWrite Property Tag As string

    Property Value

    • string
      string
      string
      string

      The unique identifier for this notification within a Group.

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.ThreadingAttribute
Windows.Foundation.Metadata.ActivatableAttribute

Details

Assembly

Windows.UI.Notifications.dll