Engaging users with live tiles and notifications

1,052 views

Published on

Presentation from Sela SDP 2012 first day

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

  • Be the first to like this

No Downloads
Views
Total views
1,052
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
0
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • This slide is hidden.. Do start with a demo of Windows 8, but don’t show the slide. Demonstrate mostly the Windows Start Menu ( aka the shell ). Make sure you use touch … Highlight the following points Windows 8 Experience  Full screen apps Live tiles  Alive and in motion  Action: Drag & rearrange tiles  Semantic  Zoom in Start Menu Search  Personalize Windows  Swap across process Pin an app  Charms   
  • Engaging users with live tiles and notifications

    1. 1. | | 25-29 March, 2012© Copyright SELA software & Education Labs Ltd. 14-18 Baruch Hirsch St.Bnei Brak 51202 Israel www.sela.co.il
    2. 2. demo
    3. 3. ITileWideSmallImageAndText03 tileContent = TileContentFactory.CreateTileWideSmallImageAndText03();tileContent.TextBodyWrap.Text = "Main tile updated fromapplication!";tileContent.Image.Src = "ms-appx:///Images/Bouquet.png";tileContent.RequireSquareContent = false;TileUpdateManager.CreateTileUpdaterForApplication().Update( tileContent.CreateNotification());
    4. 4. IToastImageAndText02 templateContent = ToastContentFactory.CreateToastImageAndText02();templateContent.TextHeading.Text = "Toast sample";templateContent.TextBodyWrap.Text = "Toast message fromapplication!";templateContent.Image.Src = "Images/NewYear.png";templateContent.Image.Alt = "Placeholder image";IToastNotificationContent toastContent = templateContent;ToastNotification toast = toastContent.CreateNotification();ToastNotificationManager.CreateToastNotifier().Show(toast);
    5. 5. BadgeNumericNotificationContent badgeContent = new BadgeNumericNotificationContent();badgeContent.Number = 23;BadgeUpdateManager.CreateBadgeUpdaterForApplication().Update( badgeContent.CreateNotification());
    6. 6. Uri logo = new Uri("ms-appx:///images/LoveIcon.png");Uri wideLogo = new Uri("ms-appx:///images/WideSecondary.png");SecondaryTile secondaryTile = newSecondaryTile("LiveTilesAndToastsSample.SecondaryTile", "Secondary tile", "Secondary tile from app", "argumets=Alex,123", TileOptions.ShowNameOnWideLogo | TileOptions.ShowNameOnLogo, logo, wideLogo);bool isPinned = await secondaryTile.RequestCreateForSelectionAsync( new Rect(10,10,100,100));
    7. 7. ITileWideSmallImageAndText03 tileContent = TileContentFactory.CreateTileWideSmallImageAndText03();tileContent.TextBodyWrap.Text = "Secondary tile updated fromapplication!";tileContent.Image.Src = "ms-appx:///Images/NewYear.png";tileContent.RequireSquareContent = false;TileUpdateManager.CreateTileUpdaterForSecondaryTile( "LiveTilesAndToastsSample.SecondaryTile").Update( tileContent.CreateNotification());
    8. 8. 1. Request Channel URI2. Register with your Cloud Service3. Authenticate & Push Notification
    9. 9. demo
    10. 10. var pushNotificationChannel = awaitPushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();var channelUri = pushNotificationChannel.Uri;//Optional channel for Secondary tileif (SecondaryTile.Exists(SecondaryTileID)){ var secondaryPushNotificationChannel = awaitPushNotificationChannelManager.CreatePushNotificationChannelForSecondaryTileAsync(SecondaryTileID); var secondaryChannelUri = secondaryPushNotificationChannel.Uri;}
    11. 11. private static Stream GetAccessToken(string sid, string secret){ string url = "https://login.live.com/accesstoken.srf"; var request = (HttpWebRequest)WebRequest.Create(url); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; string content ="grant_type=client_credentials&client_id={0}&client_secret={1}&scope=notify.windows.com"; string data = string.Format(content, sid, secret); byte[] notificationMessage = Encoding.Default.GetBytes(data);
    12. 12. request.ContentLength = notificationMessage.Length; using (Stream requestStream = request.GetRequestStream()) requestStream.Write(notificationMessage, 0, notificationMessage.Length); var response = (HttpWebResponse)request.GetResponse(); Stream result = response.GetResponseStream(); return result;}
    13. 13. private static HttpStatusCode Push(string pushUri, stringaccessToken, string type, string notificationData){ var subscriptionUri = new Uri(pushUri); var request = (HttpWebRequest)WebRequest.Create(subscriptionUri); request.Method = "POST"; request.ContentType = "text/xml"; request.Headers = new WebHeaderCollection(); request.Headers.Add("X-WNS-Type", type); request.Headers.Add("Authorization", "Bearer " + accessToken);
    14. 14. byte[] notificationMessage = Encoding.Default.GetBytes(notificationData); request.ContentLength = notificationMessage.Length; using (Stream requestStream = request.GetRequestStream()) requestStream.Write(notificationMessage, 0, notificationMessage.Length); var response = (HttpWebResponse)request.GetResponse(); return response.StatusCode;}
    15. 15. string pushUri = "https://db3.notify.windows.com/...";string secret = HttpUtility.UrlEncode("2A...");string sid = HttpUtility.UrlEncode("ms-app://s-...");var obj =System.Json.JsonObject.Load(GetAccessToken(sid, secret));string accessToken = obj["access_token"].ToString();//Send Badge notificationstring badgeNotification = "<?xml version=1.0 encoding=utf-8?><badge value="13"/>";HttpStatusCode status =Push(pushUri, accessToken, "wns/badge", badgeNotification);
    16. 16. //Send Toast notificationstring tostNotification = "<?xml version=1.0 encoding=utf-8?><toast><visual><bindingtemplate="ToastImageAndText02"><image id="1"src="Assets/Logo.png" alt="Placeholder image"/><textid="1">Urgent news</text><text id="2">New vNext meetupscheduled!</text></binding></visual></toast>";status =Push(pushUri, accessToken, "wns/toast", tostNotification);
    17. 17. //Send Tile notificationstring tileNotification = "<?xml version=1.0 encoding=utf-8?><tile><visual><bindingtemplate="TileWideSmallImageAndText03"><image id="1"src="ms-appx:///Images/Meetup.png"/><text id="1">New vNextmeetup scheduled!</text></binding></visual></tile>";status =Push(pushUri, accessToken, "wns/tile", tileNotification);
    18. 18. //Send Secondary Tile notificationpushUri = "https://db3.notify.windows.com/...";string secondaryTileNotification = "<?xml version=1.0encoding=utf-8?><tile><visual lang="en-US"><bindingtemplate="TileWidePeekImage05"><image id="1" src="ms-appx:///Images/Blog.png"/><image id="2" src="ms-appx:///Images/Avatar.png"/><text id="1">Visit myblog!</text><textid="2">http://blogs.microsoft.co.il/blogs/alex_golesh/</text></binding></visual></tile>";status =Push(pushUri, accessToken, "wns/tile", secondaryTileNotification);
    19. 19. • •• •• •• • alexg@sela.co.il

    ×