PushNotificationChannel.PushNotificationReceived Event
Definition
Raised when a push notification arrives on this channel.
// 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
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)
Event Type
Windows 10 requirements
App capabilities |
internetClient
|
Examples
The following example shows a listener for this event, which invokes the event handler.
function listeningForPushNotification() {
if (channel) {
channel.addEventListener("pushnotificationreceived", pushNotificationReceivedHandler);
}
Remarks
Windows Push Notification Services (WNS) sends this event only when the notification's target app is in the foreground. If the app is suspended, it does not receive the event.
Applies to
See also
- Windows Push Notification Services (WNS) overview
- Push and periodic notifications sample
- Quickstart: Sending a tile push notification
- Quickstart: Sending a toast push notification
- How to update a badge through push notifications
- How to authenticate with the Windows Push Notification Service (WNS)
- How to request, create, and save a notification channel
- Guidelines and checklist for push notifications
- Push notification service request and response headers