共用方式為


PushNotificationReceivedEventArgs 類別

定義

封裝已從應用程式伺服器接收的推播通知,識別類型並提供通知的內容。 Windows 會在 PushNotificationReceived 事件中傳遞此資訊。

public ref class PushNotificationReceivedEventArgs sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
class PushNotificationReceivedEventArgs final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class PushNotificationReceivedEventArgs final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
public sealed class PushNotificationReceivedEventArgs
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class PushNotificationReceivedEventArgs
Public NotInheritable Class PushNotificationReceivedEventArgs
繼承
Object Platform::Object IInspectable PushNotificationReceivedEventArgs
屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)
應用程式功能
internetClient

範例

下列範例顯示使用中這個類別的成員。

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

備註

當處理 PushNotificationReceived 事件時,您的應用程式會收到這個類別。

屬性

BadgeNotification

取得徽章更新的內容,以回應此推播通知。

Cancel

取得或設定 Windows 是否應該執行通知的預設處理。

NotificationType

取得從應用程式伺服器收到的推播通知類型。

RawNotification

取得此推播通知中包含的應用程式定義內容,其內容可用來在應用程式上執行背景工作。

TileNotification

取得要執行以回應此推播通知的磚更新內容。

ToastNotification

取得要顯示以回應此推播通知的快顯通知內容。

適用於

另請參閱