-api-id | -api-type | ms.custom |
---|---|---|
T:Windows.Networking.PushNotifications.PushNotificationReceivedEventArgs |
winrt class |
19H1 |
Encapsulates a push notification that has been received from the app server, identifying the type and supplying the content of the notification. Windows passes this information in the PushNotificationReceived event.
Your app receives this class when processing the PushNotificationReceived event.
The following example shows the members of this class in use.
function listeningForPushNotification() {
if (channel) {
channel.addEventListener("pushnotificationreceived", pushNotificationReceivedHandler);
}
function pushNotificationReceivedHandler(e) {
var notificationTypeName = "";
var notificationPayload;
switch (e.notificationType) {
// You can get the toast, tile, or badge notification object.
// In this example, we take the XML from the notification.
case pushNotifications.PushNotificationType.toast:
notificationTypeName = "Toast";
notificationPayload = e.toastNotification.content.getXml();
break;
case pushNotifications.PushNotificationType.tile:
notificationTypeName = "Tile";
notificationPayload = e.tileNotification.content.getXml();
break;
case pushNotifications.PushNotificationType.badge:
notificationTypeName = "Badge";
notificationPayload = e.badgeNotification.content.getXml();
break;
}
e.cancel = true;
}
Windows Push Notification Services (WNS) overview, Push and periodic notifications sample (archived), Quickstart: Sending a push notification, How to request, create, and save a notification channel, Push notification service request and response headers
internetClient