ToastNotifier 클래스

정의

ToastNotifier가 바인딩된 특정 앱에 알림 메시지를 발생합니다. 이 클래스를 사용하면 알림 메시지를 예약하고 제거할 수도 있습니다.

public ref class ToastNotifier sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
class ToastNotifier final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class ToastNotifier final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
public sealed class ToastNotifier
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class ToastNotifier
Public NotInheritable Class ToastNotifier
상속
Object Platform::Object IInspectable ToastNotifier
특성

Windows 요구 사항

디바이스 패밀리
Windows 10 (10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox에서 도입되었습니다.)
API contract
Windows.Foundation.UniversalApiContract (v1.0에서 도입되었습니다.)

예제

다음 예제에서는 Show 메서드 사용을 포함하여 텍스트 및 이미지가 포함된 알림 메시지를 만들고 보내는 방법을 보여 줍니다.

var notifications = Windows.UI.Notifications;

// Get the toast notification manager for the current app.
var notificationManager = notifications.ToastNotificationManager;

// The getTemplateContent method returns a Windows.Data.Xml.Dom.XmlDocument object
// that contains the toast notification XML content.
var template = notifications.ToastTemplateType.toastImageAndText01;
var toastXml = notificationManager.getTemplateContent(template);
var template = notifications.toastTemplateType.toastImageAndText01;
var toastXml = notificationManager.getTemplateContent(notifications.ToastTemplateType[template]);

// You can use the methods from the XML document to specify the required elements for the toast.
var images = toastXml.getElementsByTagName("image");
images[0].setAttribute("src", "images/toastImageAndText.png");

var textNodes = toastXml.getElementsByTagName("text");
textNodes.forEach(function (value, index) {
    var textNumber = index + 1;
    var text = "";
    for (var j = 0; j < 10; j++) {
        text += "Text input " + /*@static_cast(String)*/textNumber + " ";
    }
    value.appendChild(toastXml.createTextNode(text));
});

// Create a toast notification from the XML, then create a ToastNotifier object
// to send the toast.
var toast = new notifications.ToastNotification(toastXml);

notificationManager.createToastNotifier().show(toast);

다음 예제에서는 GetScheduledToastNotificationsRemoveFromSchedule 메서드의 사용을 보여 줍니다.

var notifier = Notifications.ToastNotificationManager.createToastNotifier();
var scheduled = notifier.getScheduledToastNotifications();                    

for (var i = 0, len = scheduled.length; i < len; i++) {

    // The itemId value is the unique ScheduledTileNotification.Id assigned to the 
    // notification when it was created.
    if (scheduled[i].id === itemId) {
        notifier.removeFromSchedule(scheduled[i]);
    }
}

설명

이 클래스를 만들면 ToastNotifier가 특정 앱에 바인딩되므로 이 클래스의 메서드는 해당 앱에만 영향을 줍니다.

버전 기록

Windows 버전 SDK 버전 추가된 값
1703 15063 Update(NotificationData,String,String)
1703 15063 Update(NotificationData,String)
1809 17763 ScheduledToastNotificationShowing

속성

Setting

알림 메시지 표시를 방지하는 앱, 사용자 또는 시스템 블록이 있는지 여부를 알려주는 값을 가져옵니다.

메서드

AddToSchedule(ScheduledToastNotification)

Windows에서 나중에 표시 할 수 있는 ScheduledToastNotification 을 추가합니다.

중요

이 메서드는 WinRT를 기본 애플리케이션 프레임워크로 사용하는 애플리케이션에서만 지원됩니다.

GetScheduledToastNotifications()

이 앱이 표시 되도록 예약된 ScheduledToastNotification 개체의 컬렉션을 가져옵니다.

중요

이 메서드는 WinRT를 기본 애플리케이션 프레임워크로 사용하는 애플리케이션에서만 지원됩니다.

Hide(ToastNotification)

화면에서 지정된 알림 메시지를 제거합니다.

RemoveFromSchedule(ScheduledToastNotification)

지정된 ScheduledToastNotification의 예약된 표시를 취소합니다.

중요

이 메서드는 WinRT를 기본 애플리케이션 프레임워크로 사용하는 애플리케이션에서만 지원됩니다.

Show(ToastNotification)

지정된 알림 메시지를 표시합니다.

Update(NotificationData, String)

지정된 태그가 있는 기존 알림 메시지를 업데이트.

Update(NotificationData, String, String)

지정된 태그가 있고 지정된 알림 그룹에 속하는 기존 알림 메시지를 업데이트.

이벤트

ScheduledToastNotificationShowing

시스템에서 예약된 알림 메시지를 표시할 때 발생합니다.

적용 대상

추가 정보