Share via


PushNotificationChannelManager.ChannelsRevoked Ereignis

Definition

Wird ausgelöst, wenn Ihr Pushkanal widerrufen wird, sodass Sie sofort einen neuen Kanal anfordern können. Dadurch werden Ausfallzeiten minimiert, die sich aus der Verwendung eines widerrufenen WNS-Kanals ergeben. Der Ereignisargumenttyp ist 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) 

Ereignistyp

Windows-Anforderungen

Gerätefamilie
Windows 10, version 2004 (eingeführt in 10.0.19041.0)
API contract
Windows.Foundation.UniversalApiContract (eingeführt in v10.0)

Beispiele

// 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.
    ...
}    

Hinweise

Sie erstellen einen Pushkanal, um Pushbenachrichtigungen von Ihrem Dienst über WNS zu empfangen. Diese Kanäle sind nicht dauerhaft und können sich aus verschiedenen Gründen ändern (am häufigsten laufen Kanäle nach dreißig Tagen ab). Es gibt auch Ereignisse, die innerhalb der Plattform auftreten können, die den Kanal widerrufen (z. B. änderungen der globalen Geräte-ID). Wenn Sie dieses Ereignis verwenden, müssen Sie jedoch nicht jedes Mal einen neuen Kanal anfordern, wenn Ihre App gestartet wird.

Gilt für: