PushNotificationReceivedEventArgs class

Applies to Windows and Windows Phone

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.

Syntax


/* For information about creating or accessing this object, see Remarks. */

Attributes

[Version(0x06020000)]

Members

The PushNotificationReceivedEventArgs class has these types of members:

Methods

The PushNotificationReceivedEventArgs class inherits methods from the Object class (C#/VB/C++).

Properties

The PushNotificationReceivedEventArgs class has these properties.

PropertyAccess typeDescription

BadgeNotification

Read-onlyGets the content of a badge update to perform in response to this push notification.

Cancel

Read/writeGets or sets whether Windows should perform its default handling of the notification.

NotificationType

Read-onlyGets the type of push notification that has been received from the app server.

RawNotification

Read-onlyGets the app-defined content contained in this push notification, the contents of which are used to perform a background task on the app.

TileNotification

Read-onlyGets the content of a tile update to perform in response to this push notification.

ToastNotification

Read-onlyGets the content of a toast to display in response to this push notification.

 

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

Requirements

Minimum supported client

Windows 8 [Windows Store apps only]

Minimum supported server

Windows Server 2012 [Windows Store apps only]

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Namespace

Windows.Networking.PushNotifications
Windows::Networking::PushNotifications [C++]

Metadata

Windows.winmd

Capabilities

internetClient

See also

WNS overview
Push and periodic notifications sample
Quickstart: Sending a tile push notification
Quickstart: Sending a toast push notification
How to update a badge through push notifications
How to authenticate with the Windows Push Notification Service (WNS)
How to request, create, and save a notification channel
Guidelines and checklist for push notifications
Push notification service request and response headers

 

 

Show:
© 2014 Microsoft