PushNotificationChannelManager.ChannelsRevoked イベント

定義

プッシュ チャネルが取り消されたときに発生し、新しいチャネルをすぐに要求できるようにします。 これにより、取り消された WNS チャネルの使用によるダウンタイムが最小限に抑えられます。 イベント引数の型は PushNotificationChannelsRevokedEventArgs です

// Register
static event_token ChannelsRevoked(EventHandler<PushNotificationChannelsRevokedEventArgs> const& handler) const;

// Revoke with event_token
static void ChannelsRevoked(event_token const* cookie) const;

// Revoke with event_revoker
static PushNotificationChannelManager::ChannelsRevoked_revoker ChannelsRevoked(auto_revoke_t, EventHandler<PushNotificationChannelsRevokedEventArgs> const& handler) const;
public static event System.EventHandler<PushNotificationChannelsRevokedEventArgs> ChannelsRevoked;
function onChannelsRevoked(eventArgs) { /* Your code */ }
Windows.Networking.PushNotifications.PushNotificationChannelManager.addEventListener("channelsrevoked", onChannelsRevoked);
Windows.Networking.PushNotifications.PushNotificationChannelManager.removeEventListener("channelsrevoked", onChannelsRevoked);
- or -
Windows.Networking.PushNotifications.PushNotificationChannelManager.onchannelsrevoked = onChannelsRevoked;
Public Shared Custom Event ChannelsRevoked As EventHandler(Of PushNotificationChannelsRevokedEventArgs) 

イベントの種類

Windows の要件

デバイス ファミリ
Windows 10, version 2004 (10.0.19041.0 で導入)
API contract
Windows.Foundation.UniversalApiContract (v10.0 で導入)

// Create the manager, and subscribe to the ChannelsRevoked event.

PushNotificationChannel channel = null;
PushNotificationChannelManager.ChannelsRevoked += OnChannelsRevoked;

try
{
    // Create the channel manager for the user.
    PushNotificationChannelManagerForUser channelManagerForUser = PushNotificationChannelManager.GetDefault();

    // Create the channel.
    channel = await channelManagerForUser.CreatePushNotificationChannelForApplicationAsync();

    // If the channel isn't null, send to app service.
    if (channel != null)
    {
        sendChannelURIToServer(channel.Uri);
    }
}
catch (Exception e){ ... }

...

private async void OnChannelsRevoked(PushNotificationChannelsRevokedEventArgs e)
{
    // PushNotificationChannelsRevokedEventArgs has no members.
    // Previous channel was revoked, time to create a new channel as shown above.
    ...
}    

注釈

WNS 経由でサービスからプッシュ通知を受信するプッシュ チャネルを作成します。 これらのチャネルは永続的ではなく、さまざまな理由で変更される可能性があります (最も一般的な理由は、チャネルが 30 日後に期限切れになることです)。 チャネルを取り消すプラットフォーム内で発生する可能性があるイベントもあります (グローバル デバイス ID の変更など)。 ただし、このイベントを使用する場合は、アプリを起動するたびに新しいチャネルを要求する必要はありません。

適用対象