Share via


PushNotificationChannelManager.ChannelsRevoked Kejadian

Definisi

Dimunculkan saat saluran push Dicabut, sehingga Anda dapat segera meminta saluran baru. Ini meminimalkan waktu henti yang dihasilkan dari penggunaan saluran WNS yang dicabut. Jenis argumen peristiwa adalah 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) 

Jenis Acara

Persyaratan Windows

Rangkaian perangkat
Windows 10, version 2004 (diperkenalkan dalam 10.0.19041.0)
API contract
Windows.Foundation.UniversalApiContract (diperkenalkan dalam v10.0)

Contoh

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

Keterangan

Anda membuat saluran push untuk menerima pemberitahuan push dari layanan Anda melalui WNS. Saluran ini tidak permanen, dan dapat berubah karena berbagai alasan (yang paling umum adalah saluran kedaluwarsa setelah tiga puluh hari). Ada juga peristiwa yang dapat terjadi dalam platform yang mencabut saluran (misalnya, ID perangkat global berubah). Tetapi Anda tidak perlu meminta saluran baru setiap kali aplikasi diluncurkan, jika Anda menggunakan acara ini.

Berlaku untuk