PushNotificationChannelManager.ChannelsRevoked Event

Definition

Raised when your push channel is revoked, so that you can immediately request a new channel. This minimizes any downtime resulting from using a revoked WNS channel. The event arguments type is 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) 

Event Type

Windows requirements

Device family
Windows 10, version 2004 (introduced in 10.0.19041.0)
API contract
Windows.Foundation.UniversalApiContract (introduced in v10.0)

Examples

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

Remarks

You create a push channel to receive push notifications from your service via WNS. These channels are not permanent, and may change for a variety of reasons (the most common being that channels expire after thirty days). There are also events that can occur within the platform that revoke the channel (for example, the global device ID changes). But you needn't request a new channel every time your app launches, if you use this event.

Applies to