23.01.2018 Views

MICROSOFT_PRESS_EBOOK_PROGRAMMING_WINDOWS_8_APPS_WITH_HTML_CSS_AND_JAVASCRIPT_PDF

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

The other bits of the manifest that affect a tile update are the Foreground Text and Background<br />

Color settings in the Application UI section. These define how tile text appears for all tile updates (and<br />

toasts for that matter), and they cannot be altered in the tile payload. This keeps the branding of the<br />

app consistent between updates; users would certainly find it confusing if multiple tiles from the same<br />

app showed up in different colors.<br />

As a quick example, the SDK sample we’ve been working with here uses Light foreground text and a<br />

background color of #00b2f0. If I go to Scenario 5, choose the TileWideText09 template, add some text,<br />

and select Logo for the branding (where the small logo contains a block with “SDK” in it), the result is as<br />

follows:<br />

Cycling, Scheduled, and Expiring Updates<br />

Although you might read the heading for this section and think it’s just going to be a grab bag of<br />

randomness, all it really means is that we’re looking at additional methods of the TileUpdater object<br />

and revisiting the two properties of the TileNotification object that we already mentioned. Simply<br />

said, now that we’ve seen how to do all the basic tile updates we’re ready to start exploring the<br />

additional capabilities. Again, everything here applies to all tiles in the app.<br />

First is the ability to programmatically clear all updates and reset the tile to its default state as<br />

defined in the manifest. This happens with a simple call to TileUpdater.clear (shown in Scenario 1):<br />

Windows.UI.Notifications.TileUpdateManager.createTileUpdaterForApplication().clear();<br />

The next capability, as already mentioned, is to set the TileNotification.expirationTime property<br />

before sending that notification to TileUpdater.update. This ensures that a locally issued notification<br />

will be automatically removed, and it lets you override the default three-day expiration period for<br />

cloud-issued updates. The update will appear immediately (at the next tile refresh, that is) and will then<br />

be removed from the tile after it expires. This is demonstrated in Scenario 7 of the sample—sending an<br />

update with an expiration date will display an update as on the left below. When it expires, it’s removed,<br />

which in this case causes the tile to revert to its default state, as shown on the right (and yeah, I’m<br />

working on this book on a Sunday night!):<br />

585

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

Saved successfully!

Ooh no, something went wrong!