ToastNotificationManager.CreateToastNotifier Methode

Definition

Überlädt

CreateToastNotifier()

Erstellt und initialisiert eine neue instance der ToastNotification, die an die aufrufende Anwendung gebunden ist, mit der Sie eine Popupbenachrichtigung für diese App auslösen können.

CreateToastNotifier(String)

Erstellt und initialisiert eine neue instance der ToastNotification, die an eine angegebene App gebunden ist, normalerweise eine andere App im selben Paket.

CreateToastNotifier()

Erstellt und initialisiert eine neue instance der ToastNotification, die an die aufrufende Anwendung gebunden ist, mit der Sie eine Popupbenachrichtigung für diese App auslösen können.

public:
 static ToastNotifier ^ CreateToastNotifier();
/// [Windows.Foundation.Metadata.Overload("CreateToastNotifier")]
 static ToastNotifier CreateToastNotifier();
[Windows.Foundation.Metadata.Overload("CreateToastNotifier")]
public static ToastNotifier CreateToastNotifier();
function createToastNotifier()
Public Shared Function CreateToastNotifier () As ToastNotifier

Gibt zurück

Das Objekt, das Sie zum Senden der Popupbenachrichtigung an die App verwenden.

Attribute

Beispiele

Das folgende Beispiel zeigt, wie Sie eine Popupbenachrichtigung erstellen und senden, die Text und Bilder enthält, einschließlich der Verwendung der CreateToastNotifier-Methode.

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

Hinweise

Verwenden Sie diese Überladung nicht, wenn Sie einen Popup-Notifier für eine Desktop-App erstellen. Verwenden Sie CreateToastNotifier(appID), um die erforderliche AppUserModelID anzugeben.

Wenn Ihre App einen VOIP-Agent (Voice-over-Internet Protocol) im Hintergrund verwendet, muss sie die App-ID angeben, um ein Popup anzuzeigen. Verwenden Sie die CreateToastNotifier(appID) -Methodenüberladung.

Weitere Informationen

Gilt für:

CreateToastNotifier(String)

Erstellt und initialisiert eine neue instance der ToastNotification, die an eine angegebene App gebunden ist, normalerweise eine andere App im selben Paket.

public:
 static ToastNotifier ^ CreateToastNotifier(Platform::String ^ applicationId);
/// [Windows.Foundation.Metadata.Overload("CreateToastNotifierWithId")]
 static ToastNotifier CreateToastNotifier(winrt::hstring const& applicationId);
[Windows.Foundation.Metadata.Overload("CreateToastNotifierWithId")]
public static ToastNotifier CreateToastNotifier(string applicationId);
function createToastNotifier(applicationId)
Public Shared Function CreateToastNotifier (applicationId As String) As ToastNotifier

Parameter

applicationId
String

Platform::String

winrt::hstring

Die eindeutige ID der App.

Hinweis

Sie können keine Popupbenachrichtigung an eine sekundäre Kachel senden, daher muss dies die ID einer App-Kachel sein.

Gibt zurück

Das Objekt, das Sie verwenden, um die Popupbenachrichtigung an die Kachel zu senden.

Attribute

Hinweise

Die durch applicationId identifizierte App muss zum gleichen Paket gehören wie der Aufrufer.

Verwenden Sie diese Form der -Methode, wenn Ihre App einen VOIP-Agent (Voice-over-Internet Protocol) im Hintergrund verwendet, um die App-ID anzugeben, die in diesem Fall zum Anzeigen eines Popups erforderlich ist.

Senden von Popupbenachrichtigungen von Desktop-Apps

Im Allgemeinen ist das Senden einer Popupbenachrichtigung von einer Desktop-App dasselbe wie das Senden von einer UWP-App. Beachten Sie jedoch die folgenden Unterschiede und Anforderungen:

  • Damit eine Desktop-App ein Popup anzeigt, muss die App über eine Verknüpfung auf dem Startbildschirm verfügen.
  • Die Verknüpfung muss über eine AppUserModelID verfügen.
  • Desktop-Apps können kein Popup planen.

Weitere Informationen finden Sie in den folgenden Themen:

Weitere Informationen

Gilt für: