ScheduledToastNotification.ScheduledToastNotification(XmlDocument, DateTime) constructor

Applies to Windows and Windows Phone

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

Syntax


var scheduledToastNotification = new Windows.UI.Notifications.ScheduledToastNotification(content, deliveryTime);

Parameters

content

Type: XmlDocument

The XML that defines the toast notification content.

deliveryTime

Type: Date [JavaScript] | System.DateTimeOffset [.NET] | Windows::Foundation::DateTime [C++]

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

Requirements

Minimum supported client

Windows 8

Minimum supported server

Windows Server 2012

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Namespace

Windows.UI.Notifications
Windows::UI::Notifications [C++]

Metadata

Windows.winmd

See also

ScheduledToastNotification
ScheduledToastNotification(XmlDocument, DateTime, TimeSpan, UInt32)
Scheduled notifications sample
Toast schema
Guidelines and checklist for scheduled notifications

 

 

Show:
© 2014 Microsoft