BadgeUpdateManager BadgeUpdateManager BadgeUpdateManager BadgeUpdateManager Class

Creates BadgeUpdater objects that you use to manipulate a tile's badge overlay. This class also provides access to the XML content of the system-provided badge templates so that you can customize that content for use in updating your badges.

Syntax

Declaration

public static class BadgeUpdateManagerpublic static class BadgeUpdateManagerPublic Static Class BadgeUpdateManager

Remarks

Examples

The following example shows the use of GetTemplateContent(Windows.UI.Notifications.BadgeTemplateType) to create the content for a numeric badge and CreateBadgeUpdaterForApplication() to send a numeric badge update to the calling app's tile.


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);
}

Methods summary

Creates and initializes a new instance of the BadgeUpdater, which lets you change the appearance or content of the badge on the calling app's tile.

Creates and initializes a new instance of the BadgeUpdater for a specified app tile's badge, usually the tile of another app in the package. The BadgeUpdater lets you change the appearance or content of that badge.

Creates and initializes a new instance of the BadgeUpdater, which enables you to change the appearance or content of a badge on a SecondaryTile. The tile can belong to the calling app or any other app in the same package.

Gets the XML content of one of the predefined badge templates so that you can customize it for a badge update.

Methods

  • CreateBadgeUpdaterForApplication()
    CreateBadgeUpdaterForApplication()
    CreateBadgeUpdaterForApplication()
    CreateBadgeUpdaterForApplication()

    Creates and initializes a new instance of the BadgeUpdater, which lets you change the appearance or content of the badge on the calling app's tile.

    public static BadgeUpdater CreateBadgeUpdaterForApplication()public static BadgeUpdater CreateBadgeUpdaterForApplication()Public Static Function CreateBadgeUpdaterForApplication() As BadgeUpdater

    Returns

    Remarks

    Examples

    The following example shows CreateBadgeUpdaterForApplication() used to send a numeric badge update to the calling app's tile.

    
    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);
    }
    
  • CreateBadgeUpdaterForApplication(System.String)
    CreateBadgeUpdaterForApplication(System.String)
    CreateBadgeUpdaterForApplication(System.String)
    CreateBadgeUpdaterForApplication(System.String)

    Creates and initializes a new instance of the BadgeUpdater for a specified app tile's badge, usually the tile of another app in the package. The BadgeUpdater lets you change the appearance or content of that badge.

    public static BadgeUpdater CreateBadgeUpdaterForApplication(System.String)public static BadgeUpdater CreateBadgeUpdaterForApplication(System.String)Public Static Function CreateBadgeUpdaterForApplication(System.String) As BadgeUpdater

    Parameters

    • applicationId
      System.String
      System.String
      System.String
      System.String

      The unique ID of the tile whose badge you want to update.

    Returns

    Remarks

    The app identified by applicationId must belong to the same package as the caller.

  • CreateBadgeUpdaterForSecondaryTile(System.String)
    CreateBadgeUpdaterForSecondaryTile(System.String)
    CreateBadgeUpdaterForSecondaryTile(System.String)
    CreateBadgeUpdaterForSecondaryTile(System.String)

    Creates and initializes a new instance of the BadgeUpdater, which enables you to change the appearance or content of a badge on a SecondaryTile. The tile can belong to the calling app or any other app in the same package.

    public static BadgeUpdater CreateBadgeUpdaterForSecondaryTile(System.String)public static BadgeUpdater CreateBadgeUpdaterForSecondaryTile(System.String)Public Static Function CreateBadgeUpdaterForSecondaryTile(System.String) As BadgeUpdater

    Parameters

    • tileId
      System.String
      System.String
      System.String
      System.String

      The unique ID of the tile.

    Returns

    Remarks

    Examples

    The following example demonstrates how to send a numeric badge notification to a secondary tile with an ID of "SecondaryTile.Dynamic".

    
    var Notifications = Windows.UI.Notifications;
    
    // Define the badge content
    var badgeNotification = Notifications.BadgeUpdateManager.getTemplateContent(Notifications.BadgeTemplateType.badgeNumber);
    var badgeAttributes = badgeNotification.getElementsByTagName("badge");
    badgeAttributes[0].setAttribute("value", "6");
    
    // Create the notification based on the XML content.
    var badge = new Notifications.BadgeNotification(badgeNotification);
    
    // Create a secondary tile updater, passing it the ID of the tile.
    Notifications.BadgeUpdateManager.createBadgeUpdaterForSecondaryTile("SecondaryTile.Dynamic");
    
    // Send the notification to the secondary tile.
    tileUpdater.update(tileNotification);
    
  • GetTemplateContent(Windows.UI.Notifications.BadgeTemplateType)
    GetTemplateContent(Windows.UI.Notifications.BadgeTemplateType)
    GetTemplateContent(Windows.UI.Notifications.BadgeTemplateType)
    GetTemplateContent(Windows.UI.Notifications.BadgeTemplateType)

    Gets the XML content of one of the predefined badge templates so that you can customize it for a badge update.

    public static XmlDocument GetTemplateContent(Windows.UI.Notifications.BadgeTemplateType)public static XmlDocument GetTemplateContent(Windows.UI.Notifications.BadgeTemplateType)Public Static Function GetTemplateContent(Windows.UI.Notifications.BadgeTemplateType) As XmlDocument

    Parameters

    Returns

    Remarks

    Instead of creating the full XML payload yourself, you can get the default template and then use Document Object Model (DOM) manipulation functions to customize the part of the content that you want to change. You package this XML in a BadgeNotification and send it to the tile through the BadgeUpdater that you create through the other methods of this class.

    See badge schema for an explanation of badge elements and attributes.

    Examples

    The following example shows the use of GetTemplateContent(Windows.UI.Notifications.BadgeTemplateType) to get the content for a numeric badge.

    
    var Notifications = Windows.UI.Notifications;
    
    var badgeXml = Notifications.BadgeUpdateManager.getTemplateContent(Notifications.BadgeTemplateType.badgeNumber);
    var badgeAttributes = badgeXml.getElementsByTagName("badge");
    badgeAttributes[0].setAttribute("value", "7");
    

Device family

Windows 10 (introduced v10.0.10240.0)

API contract

Windows.Foundation.UniversalApiContract (introduced v1)

Attributes

Windows.Foundation.Metadata.ThreadingAttribute
Windows.Foundation.Metadata.StaticAttribute
Windows.Foundation.Metadata.ContractVersionAttribute
Windows.Foundation.Metadata.MuseAttribute
Windows.Foundation.Metadata.StaticAttribute

Details

Assembly

Windows.UI.Notifications.dll