BadgeUpdateManager BadgeUpdateManager BadgeUpdateManager BadgeUpdateManager Class

Definition

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.

public : static class BadgeUpdateManagerpublic static class BadgeUpdateManagerPublic Static Class BadgeUpdateManager// You can use this class in JavaScript.
Attributes
Windows 10 requirements
Device family
Windows 10 (introduced v10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced v1)

Examples

The following example shows the use of GetTemplateContent 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

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// You can use this method in JavaScript.
Returns

The object you will use to send changes to the app tile's badge.

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

}
See Also

CreateBadgeUpdaterForApplication(String) CreateBadgeUpdaterForApplication(String) CreateBadgeUpdaterForApplication(String) CreateBadgeUpdaterForApplication(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(PlatForm::String applicationId)public static BadgeUpdater CreateBadgeUpdaterForApplication(String applicationId)Public Static Function CreateBadgeUpdaterForApplication(applicationId As String) As BadgeUpdater// You can use this method in JavaScript.
Parameters
applicationId
PlatForm::String String String String

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

Returns

The object you will use to send changes to the application tile's badge.

Remarks

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

See Also

CreateBadgeUpdaterForSecondaryTile(String) CreateBadgeUpdaterForSecondaryTile(String) CreateBadgeUpdaterForSecondaryTile(String) CreateBadgeUpdaterForSecondaryTile(String)

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

public : static BadgeUpdater CreateBadgeUpdaterForSecondaryTile(PlatForm::String tileId)public static BadgeUpdater CreateBadgeUpdaterForSecondaryTile(String tileId)Public Static Function CreateBadgeUpdaterForSecondaryTile(tileId As String) As BadgeUpdater// You can use this method in JavaScript.
Parameters
tileId
PlatForm::String String String String

The unique ID of the tile.

Returns

The object you will use to send badge updates to the tile identified by tileID.

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);
See Also

GetForUser(User) GetForUser(User) GetForUser(User) GetForUser(User)

Creates and initializes a new BadgeUpdateManagerForUser for the specified user, which lets you change the appearance or content of the badge on a tile for a specific user.

public : static BadgeUpdateManagerForUser GetForUser(User user)public static BadgeUpdateManagerForUser GetForUser(User user)Public Static Function GetForUser(user As User) As BadgeUpdateManagerForUser// You can use this method in JavaScript.
Parameters
user
User User User User

The user who will recieve the tile badge updates.

Returns

An object that will update tile badges for the specified user.

Additional features and requirements
Device family
Windows 10 Anniversary Edition (introduced v10.0.14393.0)
API contract
Windows.Foundation.UniversalApiContract (introduced v3)

GetTemplateContent(BadgeTemplateType) GetTemplateContent(BadgeTemplateType) GetTemplateContent(BadgeTemplateType) GetTemplateContent(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(BadgeTemplateType type)public static XmlDocument GetTemplateContent(BadgeTemplateType type)Public Static Function GetTemplateContent(type As BadgeTemplateType) As XmlDocument// You can use this method in JavaScript.
Parameters
type
BadgeTemplateType BadgeTemplateType BadgeTemplateType BadgeTemplateType

The type of badge template, either a glyph or a number.

Returns

The object that contains the template XML.

Examples

The following example shows the use of GetTemplateContent 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");

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 schemafor an explanation of badge elements and attributes.

See Also

See Also