23.01.2018 Views

MICROSOFT_PRESS_EBOOK_PROGRAMMING_WINDOWS_8_APPS_WITH_HTML_CSS_AND_JAVASCRIPT_PDF

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Value Glyph XML<br />

(none) n/a <br />

(number 1-99)<br />

<br />

(number over 99)<br />

<br />

activity<br />

<br />

alert<br />

<br />

available<br />

<br />

away<br />

<br />

busy<br />

<br />

newMessage<br />

<br />

paused<br />

<br />

playing<br />

<br />

unavailable<br />

<br />

error<br />

<br />

attention<br />

<br />

If you like, you can use the BadgeUpdateManager.getTemplateContent function to obtain an<br />

XmlDocument with such contents; there’s a bit of sample code on this method’s reference page that<br />

shows how. But because the XML is so simple, it’s just as easy to create the object from a string by using<br />

new Windows.Data.Xml.Dom.XmlDocument followed by a call to its loadXml method, as we’ve seen with<br />

tiles. The Notifications Extensions Library also has methods for this and doing updates. Both of these<br />

approaches are demonstrated in Scenario 6 of the App tiles and badges sample.<br />

However you create it, the next step is to instantiate a BadgeNotification with that XmlDocument:<br />

var badge = new Windows.UI.Notifications.BadgeNotification(badgeDOM);<br />

This notification object also supports an expirationTime property just like tiles do. That aside, the last<br />

step is to call BadgeUpdateManager.createBadgeUpdaterForApplication to obtain a BadgeUpdater<br />

for your app tile or—you can predict this one—BadgeUpdateManager.create- BadgeUpdater-<br />

ForSecondaryTile to obtain a BadgeUpdater for a secondary tile with a given tileId. After you obtain<br />

your BadgeNotification (and again, the Notifications Extensions Library can help here), you then call<br />

BadgeUpdate.update:<br />

588

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!