Tiles and Notifications by Jason Fox

375 views

Published on

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
375
On SlideShare
0
From Embeds
0
Number of Embeds
132
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Tiles and Notifications by Jason Fox

  1. 1. Square (1x1) Wide (2x1)
  2. 2. 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);
  3. 3. 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);
  4. 4. 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>
  5. 5. Badge Badge
  6. 6. 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);
  7. 7. 1. Request Channel URI 2. Register with your Cloud Service 3. Authenticate & Push Notification
  8. 8. © 2012 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION

×