Skip to content

Latest commit

 

History

History
56 lines (46 loc) · 2.72 KB

pushnotificationreceivedeventargs.md

File metadata and controls

56 lines (46 loc) · 2.72 KB
-api-id -api-type ms.custom
T:Windows.Networking.PushNotifications.PushNotificationReceivedEventArgs
winrt class
19H1

Windows.Networking.PushNotifications.PushNotificationReceivedEventArgs

-description

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.

-remarks

Your app receives this class when processing the PushNotificationReceived event.

-examples

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

-see-also

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

-capabilities

internetClient