PushNotificationChannel PushNotificationChannel PushNotificationChannel PushNotificationChannel Class

Represents a delivery vehicle and addressing mechanism for push notifications.

The channel Uniform Resource Identifier (URI)represented by this interface is used by a third-party application server to communicate with the Windows Push Notification Services (WNS). The push notification channel is used by the client to intercept notifications.

Syntax

Declaration

public sealed class PushNotificationChannelpublic sealed class PushNotificationChannelPublic NotInheritable Class PushNotificationChannel

Remarks

This object is returned through an instance of the IAsyncOperation<TResult> interface which is returned through the CreatePushNotificationChannelForApplicationAsync(System.String) method. When the asynchronous operation completes successfully, it returns the PushNotificationChannel object through a then or done method.

Properties summary

Gets the time at which the channel expires. Notifications sent to this channel after this time are rejected.

Gets the Uniform Resource Identifier (URI) to which an app server sends a push notification intended for an application or secondary tile bound to this channel. This Uniform Resource Identifier (URI) is transmitted to and stored by the third-party app server.

Methods summary

Explicitly invalidates this channel. Any notifications pushed to this channel after this method is called are not delivered.

Events summary

Fires when a push notification has arrived on this channel.

Properties

  • ExpirationTime
    ExpirationTime
    ExpirationTime
    ExpirationTime

    Gets the time at which the channel expires. Notifications sent to this channel after this time are rejected.

    public DateTime ExpirationTime { get; }public DateTime ExpirationTime { get; }Public ReadOnly Property ExpirationTime As DateTime

    Property Value

    Remarks

    To prevent a channel from expiring, apps should request a new push notification channel every time that the app is run.

    An expired channel behaves as though it was closed. Because channels cannot be renewed, after a channel expires, a secondary tile or application must request a new push notification channel.

  • Uri
    Uri
    Uri
    Uri

    Gets the Uniform Resource Identifier (URI) to which an app server sends a push notification intended for an application or secondary tile bound to this channel. This Uniform Resource Identifier (URI) is transmitted to and stored by the third-party app server.

    public string Uri { get; }public string Uri { get; }Public ReadOnly Property Uri As string

    Property Value

    • string
      string
      string
      string

      The Uniform Resource Identifier (URI) (https) that the app server uses to post notifications.

Methods

  • Close()
    Close()
    Close()
    Close()

    Explicitly invalidates this channel. Any notifications pushed to this channel after this method is called are not delivered.

    public void Close()public void Close()Public Function Close() As void

    Remarks

    After it has been closed, the channel can never be used again. Channels that are closed through this method are no different than channels that have expired. To resume sending push notifications to this app, the app must request a new channel.

    Calling Close() on a channel invalidates the underlying URI as well as any non-expired, non-closed URIs previously created for the app.

Events

  • PushNotificationReceived
    PushNotificationReceived
    PushNotificationReceived
    PushNotificationReceived

    Fires when a push notification has arrived on this channel.

    public event TypedEventHandler PushNotificationReceivedpublic event TypedEventHandler PushNotificationReceivedPublic Event PushNotificationReceived

    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.

    Examples

    The following example shows a listener for this event, which invokes the event handler.

    
    function listeningForPushNotification() {
        if (channel) {
            channel.addEventListener("pushnotificationreceived", pushNotificationReceivedHandler);
    }
    

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Capabilities

internetClient

Attributes

Windows.Foundation.Metadata.ContractVersionAttribute

Details

Assembly

Windows.Networking.PushNotifications.dll