ScheduledToastNotification コンストラクター

定義

オーバーロード

ScheduledToastNotification(XmlDocument, DateTime)

ScheduledToastNotification の新しいインスタンスを作成して初期化します。このインスタンスは 1 回だけ表示されます。

ScheduledToastNotification(XmlDocument, DateTime, TimeSpan, UInt32)

Windows 10では非推奨です。 Windows 8 システムでは、 ScheduledToastNotification の新しいインスタンスを作成して初期化します。このインスタンスは、最初に表示された後、指定した時刻の後に再表示されます。 Windows 10では、この関数は ScheduledToastNotification(XmlDocument, DateTime) と同等に機能します。 Windows 10で同じ再通知間隔の動作を実現するには、トーストでボタンを使用できます。

ScheduledToastNotification(XmlDocument, DateTime)

ScheduledToastNotification の新しいインスタンスを作成して初期化します。このインスタンスは 1 回だけ表示されます。

public:
 ScheduledToastNotification(XmlDocument ^ content, DateTime deliveryTime);
 ScheduledToastNotification(XmlDocument const& content, DateTime const& deliveryTime);
public ScheduledToastNotification(XmlDocument content, System.DateTimeOffset deliveryTime);
function ScheduledToastNotification(content, deliveryTime)
Public Sub New (content As XmlDocument, deliveryTime As DateTimeOffset)

パラメーター

content
XmlDocument

トースト通知コンテンツを定義する XML。

deliveryTime
DateTime DateTimeOffset

Windows でトースト通知を表示する日付と時刻。 この時刻の前 に AddToSchedule を呼び出す必要があります。

次の例は、このコンストラクターを使用して通知を作成するなど、1 時間以内に表示されるようにスケジュールされたトースト通知を示しています。

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)

Windows 10では非推奨です。 Windows 8 システムでは、 ScheduledToastNotification の新しいインスタンスを作成して初期化します。このインスタンスは、最初に表示された後、指定した時刻の後に再表示されます。 Windows 10では、この関数は ScheduledToastNotification(XmlDocument, DateTime) と同等に機能します。 Windows 10で同じ再通知間隔の動作を実現するには、トーストでボタンを使用できます。

public:
 ScheduledToastNotification(XmlDocument ^ content, DateTime deliveryTime, TimeSpan snoozeInterval, unsigned int maximumSnoozeCount);
 ScheduledToastNotification(XmlDocument const& content, DateTime const& deliveryTime, TimeSpan const& snoozeInterval, uint32_t const& maximumSnoozeCount);
public ScheduledToastNotification(XmlDocument content, System.DateTimeOffset deliveryTime, System.TimeSpan snoozeInterval, uint maximumSnoozeCount);
function ScheduledToastNotification(content, deliveryTime, snoozeInterval, maximumSnoozeCount)
Public Sub New (content As XmlDocument, deliveryTime As DateTimeOffset, snoozeInterval As TimeSpan, maximumSnoozeCount As UInteger)

パラメーター

content
XmlDocument

トースト通知コンテンツを定義する XML。

deliveryTime
DateTime DateTimeOffset

Windows が最初にトースト通知を表示する日付と時刻。 この時刻の前 に AddToSchedule を呼び出す必要があります。

snoozeInterval
TimeSpan TimeSpan

通知が発生するまでの時間。 有効にするには、この値を 60 秒以上 60 分以下にする必要があります。

maximumSnoozeCount
UInt32

unsigned int

uint32_t

この通知を表示する最大回数。 有効な値の範囲は 1 ~ 5 です。

次の例では、このコンストラクターを使用して通知を作成し、60 秒の再通知間隔と通知を表示する最大 5 回を指定するなど、1 時間で表示されるようにスケジュールされたトースト通知を示します。

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

注釈

この種類の再通知間隔のスケジュールされたトースト通知は、再通知アラームのような機能に適しています。 たとえば、通知がアプリによってスケジュールから明示的に削除されない限り、最大再通知数に達するまで 5 分ごとに通知を表示できます。

重要

アプリは、ユーザーがタッチまたはクリックで通知をアクティブにした後、スケジュールから通知を削除する役割を担います。 これを行わないと、ユーザーが既に処理している場合でも、最大再通知数に達するまで通知が再び表示される可能性があります。

月や年などの長い再通知間隔をスケジュールする場合は、この方法ではなく、個々のスケジュールされたトーストを使用することをお勧めします。 これは、夏時間またはうるう年によって発生するタイミング エラーを回避します。

次のコードは、 myData から始まるトーストを最大 3 回 5 分ごとに表示する、このメソッドの呼び出しを示しています。

new ScheduledToastNotification(toast1, myDate, 60000, 3)

こちらもご覧ください

適用対象