9. JS: Creating a Basic Tile
var Notifications = Windows.UI.Notifications;
//Pick a template for your tile and get its XML contents
var tileXml = Notifications.TileUpdateManager.getTemplateContent(
Notifications.TileTemplateType.tileWideText03);
//Supply template content through document object model (DOM) methods
var tileAttributes = tileXml.getElementsByTagName("text");
tileAttributes[0].appendChild(tileXml.createTextNode("My very own tile notification"));
var squareTileImageAttributes = tileXml.getElementsByTagName("image");
squareTileImageAttributes[0].setAttribute("src", "ms-resource:images/graySquare.png");
//Create the notification based on the XML content you've specified
var tileNotification = new Notifications.TileNotification(tileXml);
//Send the notification to the app tile.
Notifications.TileUpdateManager.createTileUpdaterForApplication().update(tileNotification);
10. C#: Creating a Basic Tile
var updater = TileUpdateManager.CreateTileUpdaterForApplication();
//tell the updater to cycle through the queue
updater.EnableNotificationQueue(true
//use this for square image and text
var tileTemplate = TileUpdateManager.GetTemplateContent(TileTemplateType.TileSquareImage);
var xDocument = System.Xml.Linq.XDocument.Parse(tileTemplate.GetXml());
xDocument.Root.Element("visual").
Element("binding").Element("image").Attribute(XName.Get("src")).Value = imageUri;
//set this for wide image and text
Windows.Data.Xml.Dom.XmlDocument xmlDocument = new Windows.Data.Xml.Dom.XmlDocument();
xmlDocument.LoadXml(xDocument.ToString());
var tileNotification = new TileNotification(xmlDocument);
updater.Update(tileNotification);
11. Square and Wide Tile in One XML
<tile>
<visual lang="en-US">
<binding template="TileSquareImage">
<image id="1" src="ms-appx:///images/graySquare.png"/>
</binding>
<binding template="TileWideImageAndText01">
<image id="1" src="ms-appx:///images/redWide.png"/>
<text id="1">This tile uses images</text>
</binding>
</visual>
</tile>
13. Updating a Badge
var Notifications = Windows.UI.Notifications;
// Select to display a number
var badgeXml = Notifications.BadgeUpdateManager.getTemplateContent(
Notifications.BadgeTemplateType.badgeNumber);
// Assign a value to the badge
var badgeAttributes = badgeXml.getElementsByTagName("badge");
badgeAttributes[0].setAttribute("value", "7");
// Create the badge notification and send it to the badge
var badgeNotification = new Notifications.BadgeNotification(badgeXml);
Notifications.BadgeUpdateManager.createBadgeUpdaterForApplication().update(
badgeNotification);
14.
15.
16.
17.
18.
19.
20.
21.
22.
23. 1. Request Channel URI
2. Register with your Cloud Service
3. Authenticate & Push Notification