PushNotificationChannelManager 類別

定義

建立用來從 Windows 推播通知服務擷取推播通知通道的物件, (WNS) 。 這些通道會系結至應用程式或 次要磚

public ref class PushNotificationChannelManager abstract sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.MTA)]
class PushNotificationChannelManager final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.MTA)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class PushNotificationChannelManager final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.MTA)]
public static class PushNotificationChannelManager
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.MTA)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public static class PushNotificationChannelManager
Public Class PushNotificationChannelManager
繼承
Object Platform::Object IInspectable PushNotificationChannelManager
屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)
應用程式功能
internetClient

範例

下列範例示範如何使用 CreatePushNotificationChannelForApplicationAsync 方法來擷取呼叫應用程式的推播通知通道。

var pushNotifications = Windows.Networking.PushNotifications;
var channel;

function openNotificationsChannel() {
    var channelOperation = pushNotifications.PushNotificationChannelManager.createPushNotificationChannelForApplicationAsync();
    return channelOperation.then(function (newChannel) {
        channel = newChannel;
    }
);

下列範例示範如何使用 CreatePushNotificationChannelForSecondaryTileAsync 方法來擷取次要磚的推播通知通道。

var pushNotifications = Windows.Networking.PushNotifications;
var channel;

pushNotifications.PushNotificationChannelManager.createPushNotificationChannelForSecondaryTileAsync(myTileId).then(function (channel) {
    // Your code here.
})

備註

版本歷程記錄

Windows 版本 SDK 版本 已新增值
1607 14393 GetForUser
1703 15063 GetDefault
2004 19041 ChannelsRevoked

方法

CreatePushNotificationChannelForApplicationAsync()

建立物件,系結至呼叫的應用程式,您可以從 Windows 推播通知服務擷取推播通知通道, (WNS) 。

CreatePushNotificationChannelForApplicationAsync(String)

建立物件,系結至指定的應用程式,您可以從 Windows 推播通知服務擷取推播通知通道, (WNS) 。 指定的應用程式必須與呼叫的應用程式位於相同的套件中。 此多載應該只能從多應用程式套件呼叫,大部分的應用程式都應該使用 沒有 參數的方法。

CreatePushNotificationChannelForSecondaryTileAsync(String)

建立物件,系結至 次要磚,您可以從 Windows 推播通知服務擷取推播通知通道, (WNS) 。 磚可以是呼叫應用程式的次要磚,或相同套件中的任何其他應用程式。

GetDefault()

取得使用中使用者的管理員。

GetForUser(User)

取得指定使用者的推播通知。

事件

ChannelsRevoked

當您的推播通道遭到撤銷時引發,以便您可以立即要求新的通道。 這可將使用撤銷的 WNS 通道所產生的任何停機時間降到最低。 事件引數類型為 PushNotificationChannelsRevokedEventArgs

適用於

另請參閱