PushNotificationReceivedEventArgs PushNotificationReceivedEventArgs PushNotificationReceivedEventArgs PushNotificationReceivedEventArgs Class

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

Declaration

public sealed class PushNotificationReceivedEventArgspublic sealed class PushNotificationReceivedEventArgsPublic NotInheritable Class PushNotificationReceivedEventArgs

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

Properties summary

Gets the content of a badge update to perform in response to this push notification.

Gets or sets whether Windows should perform its default handling of the notification.

Gets the type of push notification that has been received from the app server.

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

Gets the content of a tile update to perform in response to this push notification.

Gets the content of a toast to display in response to this push notification.

Properties

  • BadgeNotification
    BadgeNotification
    BadgeNotification
    BadgeNotification

    Gets the content of a badge update to perform in response to this push notification.

    public BadgeNotification BadgeNotification { get; }public BadgeNotification BadgeNotification { get; }Public ReadOnly Property BadgeNotification As BadgeNotification

    Property Value

  • Cancel
    Cancel
    Cancel
    Cancel

    Gets or sets whether Windows should perform its default handling of the notification.

    public bool Cancel { get; set; }public bool Cancel { get; set; }Public ReadWrite Property Cancel As bool

    Property Value

    • bool
      bool
      bool
      bool

      True to prevent default processing of the notification by Windows, otherwise false. The default value is false.

  • NotificationType
    NotificationType
    NotificationType
    NotificationType

    Gets the type of push notification that has been received from the app server.

    public PushNotificationType NotificationType { get; }public PushNotificationType NotificationType { get; }Public ReadOnly Property NotificationType As PushNotificationType

    Property Value

    Remarks

    Channels bound to secondary tiles will only accept push notifications for Tile and Badge updates. Toast and Raw notifications must use a channel bound to an application.

  • RawNotification
    RawNotification
    RawNotification
    RawNotification

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

    public RawNotification RawNotification { get; }public RawNotification RawNotification { get; }Public ReadOnly Property RawNotification As RawNotification

    Property Value

  • TileNotification
    TileNotification
    TileNotification
    TileNotification

    Gets the content of a tile update to perform in response to this push notification.

    public TileNotification TileNotification { get; }public TileNotification TileNotification { get; }Public ReadOnly Property TileNotification As TileNotification

    Property Value

  • ToastNotification
    ToastNotification
    ToastNotification
    ToastNotification

    Gets the content of a toast to display in response to this push notification.

    public ToastNotification ToastNotification { get; }public ToastNotification ToastNotification { get; }Public ReadOnly Property ToastNotification As ToastNotification

    Property Value

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Capabilities

internetClient

Attributes

Windows.Foundation.Metadata.ContractVersionAttribute

Details

Assembly

Windows.Networking.PushNotifications.dll