ScheduledToastNotification
ScheduledToastNotification
ScheduledToastNotification
ScheduledToastNotification
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// You can use this class in JavaScript.
- Attributes
| 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) 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)// You can use this method in JavaScript.
- content
- XmlDocument XmlDocument XmlDocument XmlDocument
The XML that defines the toast notification content.
- deliveryTime
- DateTime DateTimeOffset DateTimeOffset DateTimeOffset
The date and time that Windows should display the toast notification. You must call AddToSchedule before this time.
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(XmlDocument, DateTime, TimeSpan, UInt32) 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)// You can use this method in JavaScript.
- content
- XmlDocument XmlDocument XmlDocument XmlDocument
The XML that defines the toast notification content.
- deliveryTime
- DateTime DateTimeOffset 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 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 UInt32
The maximum number of times to display this notification. Valid values range from 1 to 5.
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 Content
Gets the XML that defines this scheduled toast notification.
public : XmlDocument Content { get; }public XmlDocument Content { get; }Public ReadOnly Property Content As XmlDocument// You can use this property in JavaScript.
The object that contains the XML.
- See Also
DeliveryTime 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// You can use this property in JavaScript.
- Value
- DateTime DateTimeOffset DateTimeOffset DateTimeOffset
The time that this toast notification is scheduled to be displayed.
- See Also
Group 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// You can use this property in JavaScript.
- Value
- PlatForm::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 : PlatForm::String Id { get; set; }public string Id { get; set; }Public ReadWrite Property Id As string// You can use this property in JavaScript.
- Value
- PlatForm::String string string string
The identifier. This string is limited to 16 characters.
- See Also
MaximumSnoozeCount MaximumSnoozeCount MaximumSnoozeCount MaximumSnoozeCount
Gets the maximum number of times to display this notification.
public : unsigned int MaximumSnoozeCount { get; }public uint MaximumSnoozeCount { get; }Public ReadOnly Property MaximumSnoozeCount As uint// You can use this property in JavaScript.
- Value
- unsigned int 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.
- See Also
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// You can use this property in JavaScript.
true to enable notification mirroring; otherwise, false.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
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 : PlatForm::String RemoteId { get; set; }public string RemoteId { get; set; }Public ReadWrite Property RemoteId As string// You can use this property in JavaScript.
- Value
- PlatForm::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.
| Device family |
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
|
| API contract |
Windows.Foundation.UniversalApiContract (introduced v3)
|
SnoozeInterval 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>// You can use this property in JavaScript.
- Value
- IReference<TimeSpan> Nullable<TimeSpan> Nullable<TimeSpan> Nullable<TimeSpan>
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.
- See Also
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 : PlatForm::Boolean SuppressPopup { get; set; }public bool SuppressPopup { get; set; }Public ReadWrite Property SuppressPopup As bool// You can use this property in JavaScript.
- Value
- PlatForm::Boolean 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 : PlatForm::String Tag { get; set; }public string Tag { get; set; }Public ReadWrite Property Tag As string// You can use this property in JavaScript.
- Value
- PlatForm::String string string string
The unique identifier for this notification within a Group.