Dela via


BadgeUpdater Class

Definition

Updates a badge overlay on the specific tile that the updater is bound to.

public ref class BadgeUpdater sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
class BadgeUpdater final
/// [Windows.Foundation.Metadata.ContractVersion(Windows.Foundation.UniversalApiContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class BadgeUpdater final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
public sealed class BadgeUpdater
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.Foundation.UniversalApiContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class BadgeUpdater
Public NotInheritable Class BadgeUpdater
Inheritance
Object Platform::Object IInspectable BadgeUpdater
Attributes

Windows requirements

Device family
Windows 10 (introduced in 10.0.10240.0 - for Xbox, see UWP features that aren't yet supported on Xbox)
API contract
Windows.Foundation.UniversalApiContract (introduced in v1.0)

Examples

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

Remarks

To get an instance of this object, call the BadgeUpdateManager.CreateBadgeUpdaterForApplication or BadgeUpdateManager.CreateBadgeUpdaterForSecondaryTile method.

When it is created, BadgeUpdater is bound to a specific app or secondary tile, so the methods of this class affect only the single tile that the object instance is bound to.

Methods

Clear()

Removes the badge from the tile that the updater is bound to.

StartPeriodicUpdate(Uri, DateTime, PeriodicUpdateRecurrence)

Begins a series of timed updates for the badge from a web resource that the updater is bound to. Updates begin at a specified time. Note that only web resources (http/https) are allowed in a periodic update.

StartPeriodicUpdate(Uri, PeriodicUpdateRecurrence)

Begins a series of timed updates for the badge from a web resource that the updater is bound to, beginning immediately. Note that only web resources (http/https) are allowed in a periodic update.

StopPeriodicUpdate()

Cancels the current series of timed updates for the badge that the updater is bound to.

Update(BadgeNotification)

Applies a change to the badge's glyph or number.

Applies to

See also