PushNotificationChannelManager.ChannelsRevoked Kejadian
Definisi
Penting
Beberapa informasi terkait produk prarilis yang dapat diubah secara signifikan sebelum dirilis. Microsoft tidak memberikan jaminan, tersirat maupun tersurat, sehubungan dengan informasi yang diberikan di sini.
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
Saran dan Komentar
https://aka.ms/ContentUserFeedback.
Segera hadir: Sepanjang tahun 2024 kami akan menghentikan penggunaan GitHub Issues sebagai mekanisme umpan balik untuk konten dan menggantinya dengan sistem umpan balik baru. Untuk mengetahui informasi selengkapnya, lihat:Kirim dan lihat umpan balik untuk