PushNotificationChannel.PushNotificationReceived 事件
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
當推播通知到達此通道時引發。
// Register
event_token PushNotificationReceived(TypedEventHandler<PushNotificationChannel, PushNotificationReceivedEventArgs const&> const& handler) const;
// Revoke with event_token
void PushNotificationReceived(event_token const* cookie) const;
// Revoke with event_revoker
PushNotificationChannel::PushNotificationReceived_revoker PushNotificationReceived(auto_revoke_t, TypedEventHandler<PushNotificationChannel, PushNotificationReceivedEventArgs const&> const& handler) const;
public event TypedEventHandler<PushNotificationChannel,PushNotificationReceivedEventArgs> PushNotificationReceived;
function onPushNotificationReceived(eventArgs) { /* Your code */ }
pushNotificationChannel.addEventListener("pushnotificationreceived", onPushNotificationReceived);
pushNotificationChannel.removeEventListener("pushnotificationreceived", onPushNotificationReceived);
- or -
pushNotificationChannel.onpushnotificationreceived = onPushNotificationReceived;
Public Custom Event PushNotificationReceived As TypedEventHandler(Of PushNotificationChannel, PushNotificationReceivedEventArgs)
事件類型
Windows 需求
應用程式功能 |
internetClient
|
範例
下列範例顯示這個事件的接聽程式,此事件會叫用事件處理常式。
function listeningForPushNotification() {
if (channel) {
channel.addEventListener("pushnotificationreceived", pushNotificationReceivedHandler);
}
備註
只有在通知的目標應用程式位於前景時,Windows 推播通知服務 (WNS) 才會傳送此事件。 如果應用程式已暫停,則不會收到事件。