BadgeUpdateManager 類別

定義

建立您用來操作磚徽章重迭的 BadgeUpdater 物件。 此類別也可讓您存取系統提供的徽章範本的 XML 內容,以便自訂該內容以用於更新徽章。

public ref class BadgeUpdateManager abstract sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.MTA)]
class BadgeUpdateManager 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 BadgeUpdateManager final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.MTA)]
public static class BadgeUpdateManager
[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 BadgeUpdateManager
Public Class BadgeUpdateManager
繼承
Object Platform::Object IInspectable BadgeUpdateManager
屬性

Windows 需求

裝置系列
Windows 10 (已於 10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox 引進)
API contract
Windows.Foundation.UniversalApiContract (已於 v1.0 引進)

範例

下列範例示範如何使用 GetTemplateContent 來建立數值徽章的內容,並建立 CreateBadgeUpdaterForApplication 將數值徽章更新傳送至呼叫應用程式的磚。

function sendBadgeNotification() {
    var Notifications = Windows.UI.Notifications;
    var badgeXml;
    var badgeAttributes;

    // Get an XML DOM version of a specific template by using getTemplateContent.
    badgeXml = Notifications.BadgeUpdateManager.getTemplateContent(Notifications.BadgeTemplateType.badgeNumber);
    badgeAttributes = badgeXml.getElementsByTagName("badge");
    badgeAttributes[0].setAttribute("value", "7");

    // Create a badge notification from the XML content.
    var badgeNotification = new Notifications.BadgeNotification(badgeXml);

    // Send the badge notification to the app's tile.
    Notifications.BadgeUpdateManager.createBadgeUpdaterForApplication().update(badgeNotification);
}

備註

版本歷程記錄

Windows 版本 SDK 版本 已新增值
1607 14393 GetForUser

方法

CreateBadgeUpdaterForApplication()

建立並初始化 BadgeUpdater的新實例,可讓您變更呼叫應用程式磚上徽章的外觀或內容。

CreateBadgeUpdaterForApplication(String)

為指定的應用程式磚徽章建立並初始化 BadgeUpdater 的新實例,通常是套件中另一個應用程式的磚。 BadgeUpdater可讓您變更該徽章的外觀或內容。

CreateBadgeUpdaterForSecondaryTile(String)

建立並初始化 BadgeUpdater的新實例,可讓您變更 次要磚上徽章的外觀或內容。 圖格可以屬於呼叫的應用程式或任何其他相同套件中的應用程式。

GetForUser(User)

為指定的使用者建立並初始化新的 BadgeUpdateManagerForUser ,這可讓您變更特定使用者磚上徽章的外觀或內容。

GetTemplateContent(BadgeTemplateType)

取得其中一個預先定義徽章範本的 XML 內容,以便您可以自訂徽章更新。

適用於

另請參閱