Upload
steven-ira-rice
View
213
Download
0
Tags:
Embed Size (px)
Citation preview
Alive with activityTiles, notifications, and background tasksKraig BrockschmidtSenior Program Manager, Windows Ecosystem TeamAuthor, Programming Windows 8 Apps with HTML, CSS, and JavaScript3-101
Visual tour: understanding the user experienceThree ways an app configures updatesThe role of background tasks for notificationsWriting and debugging web services for notifications
Agenda
How do we create an environment that’s “alive with
activity”without having apps running
all the time?
Demo: a visual tour
Live tiles
Updates include both square and wide tiles
Tiles updated using pre-defined templates
Text-only, image-only or combination
JPEG, GIF, or PNG, max size 200 KB, max 1024px size
Optional “peek” animation
Local, scheduled, periodic and push updates
Toast templates
The lock screen
App content
Alive with activity without apps running
Issue direct updates, perhaps using queue, scheduled, and expiring updates
Tell Windows a service URL where it can to obtain periodic updates
Obtain a Windows Push Notification Service (WNS) channel and have a service send notifications to that
These actions can happen from app code or background tasks
There are three ways an app configures thisto happen
What makes an update?
Choices: Tile template catalog, badge catalog, toast template catalog, plus Toast audio options catalog
Whoever issues an update builds the XMLURIs for images can use http[s]://, ms-appx:///, orms-appdata:///local/
Notifications Extensions Library providesan object modelReduces mistakes that cause updates to not show
Tiles, badges, and toasts are bits of XML that come from predefined templates (to avoid chaos)
XML badge update schema<?xml version="1.0" encoding="utf-8" ?><badge value = "1-99" | "none" | "activity" | "alert" | "available" | "away" | ... version? = "integer" />
XML tile update schema<?xml version="1.0" encoding="utf-8" ?><tile> <visual version? = "integer" lang? = "string" baseUri? = "anyURI" branding? = "none" addImageQuery? = "boolean" >
<!-- One or more binding elements --> <binding template = "TileSquareImage" | "TileSquareBlock" | ... fallback? = "string" lang? = "string" baseUri? = "anyURI" branding? = "none" addImageQuery? = "boolean" >
<!-- Some combination of image and text --> <image id = "integer" src = "string" alt? = "string" addImageQuery? = "boolean" /> <text id = "integer" lang? = "string" /> </binding> </visual></tile>
XML toast notification schema<?xml version="1.0" encoding="utf-8" ?><toast launch? = "string" duration? = "long" | "short" > <visual version? = "integer" lang? = "string" baseUri? = "anyURI" branding? = "none" addImageQuery? = "boolean" >
<!-- One or more bindings --> <binding template = "ToastImageAndText01" | "ToastImageAndText02" | ...="" fallback? = "string" lang? = "string" baseUri? = "anyURI" branding? = "none" addImageQuery? = "boolean" >
<!-- Some number of child elements --> <image id = "integer" src = "string" alt = "string" addImageQuery? = "boolean" /> <text id = "integer" lang? = "string" /> </binding> </visual>
<!-- Optional audio --> <audio src? = "ms-winsoundevent:Notification.Default" |... loop? = "boolean" silent? = "boolean" /></toast>
Secondary tiles
Tiles created by “pinning” content from app
Pin initiated by app via simple runtime call
User confirms pin operation via system UI
Exposes a personalized surface for app
Increases Start screen presence
Same capabilities as app tiles
Launch leads to relevant content
See Windows.UI.StartScreen.SecondaryTiles classand Secondary Tiles Sample
Issuing updates from the app
Running app orbackground
task
Tile and badge API
toast API
In Windows.UI.Notifications namespace:TileNotification >> TileUpdater, SecondaryTileUpdaterBadgeNotification >> BadgeUpdaterToastNotification >> ToastNotifier
Updates appear immediately
Scheduled notifications
In Windows.UI.Notifications namespace:ScheduledTileNotification >> TileUpdater, SecondaryTileUpdaterScheduledToastNotification >> ToastNotifier
Running app or
background task
Scheduled notification API
Queue
System process
Suspendedor not running
Configuring periodic updates
In Windows.UI.Notifications namespace:TileUpdater.StartPeriodicUpdate and StartPeriodicUpdateBatchBadgeUpdater.StartPeriodicUpdate
Running app or
background task
Tile and badge updater API
System process30m to 24h frequency per service
Suspendedor not running
URI
web service
HTTP Request
Demo: writing and debugging aperiodic update service
Configuring push notifications
Running app: PushNotificationChannel.PushNotificationReceived event(in Windows.Networking.PushNotifications namespace)
Background task: PushNotificationTrigger
Running app or
background task
Channel request API
Suspendedor not running
Send channel to web service
WNS
Sendupdate
Push updatesto client (tile, badge,toast, raw)
web service
Register the app via Store dashboard
Demo: writing and debugging aservice for WNS
Building a Cloud Service with Window Azure
How do I do that with Windows Azure?
Windows Azure Mobile Services
www.WindowsAzure.com/mobile
11/1 4:15pm - Baker – Windows 8 Connectathon with Windows Azure Mobile Services (3-129)
Also see offerings from Urban Airship:http://urbanairship.com
What a push service needs to support:
Secure service API for channel URI registration
Persistent storage ofchannel URIs
Storage for tile andtoast images
Building a cloud service withWindows Azure
Background tasks for notificationsMaintenance triggers – monitor state changes, renew WNS channelsSystem triggers - AC power, non-lock screen
InternetAvailable, NetworkStateChange for connectivityLockScreenApplication[Added | Removed]ServicingComplete app has been updated
Lock screen triggers - AC or battery powerControlChannelTrigger (sockets for RTC), TimeTrigger,SessionConnected, UserAway, UserPresentPushNotificationTrigger to receive raw notifications
All tasks subject to CPU and network activity quotasIndependent of main app (can use mixed languages)
Renewing WNS channels (register task, C#)using Windows.ApplicationModel.Background;
BackgroundTaskBuilder taskBuilder = new BackgroundTaskBuilder();MaintenanceTrigger trigger = new MaintenanceTrigger( 10 * 24 * 60, false); //10 * 24 * 60 == 10 daystaskBuilder.SetTrigger(trigger);//In JavaScript, taskEntryPoint is the path of a .js filetaskBuilder.TaskEntryPoint = "PushNotificationsHelper.MaintenanceTask";taskBuilder.Name = "UpdateChannels";
SystemCondition internetCondition = new SystemCondition( SystemConditionType.InternetAvailable);taskBuilder.AddCondition(internetCondition);taskBuilder.Register();
Renewing WNS channels (task, C#)using System;using System.Threading.Tasks;using Windows.ApplicationModel.Background;
namespace PushNotificationsHelper { public sealed class MaintenanceTask : IBackgroundTask { public void Run(IBackgroundTaskInstance taskInstance) { // This is a helper function to renew WNS channels. // Important here to not block the UI thread. Notifier notifier = new Notifier(); notifier.RenewAllAsync(false).AsTask().Wait(); } }}
Renewing WNS channels (task, JavaScript)// This code runs as a web worker(function () { // Import the Notifier helper object importScripts("//Microsoft.WinJS.1.0/js/base.js"); importScripts("notifications.js");
var closeFunction = function () { close(); // This is worker.close };
var notifier = new SampleNotifications.Notifier(); notifier.renewAllAsync().done(closeFunction, closeFunction);})();
Receiving raw notification (register task, C#)using Windows.ApplicationModel.Background;using Windows.Networking.PushNotifications;
BackgroundTaskBuilder taskBuilder = new BackgroundTaskBuilder();PushNotificationTrigger trigger = new PushNotificationTrigger();taskBuilder.SetTrigger(trigger);taskBuilder.TaskEntryPoint = "BackgroundTasks.RawNotification";taskBuilder.Name = "ReceiveRawNotification";taskBuilder.Register();
Receiving raw notification (task, C#)using System.Diagnostics;using Windows.ApplicationModel.Background;using Windows.Networking.PushNotifications;using Windows.Storage;
namespace BackgroundTasks { public sealed class RawNotification : IBackgroundTask { public void Run(IBackgroundTaskInstance taskInstance) { // Get the background task details ApplicationDataContainer settings = ApplicationData.Current.LocalSettings;
// Store the content received from the notification so it // can be retrieved from the UI. RawNotification notification = (RawNotification)taskInstance.TriggerDetails; settings.Values[taskName] = notification.Content; } }}
Capability summary for notifications
Notification type Cycling Scheduled Expiring Recurring Audio Periodic Push
Tile ✔ ✔ ✔ ✔ ✔
Badge ✔✔
✔
Toast ✔ ✔ ✔ ✔ ✔
Raw ✔
www.buildwindows.com
When should I update my tile or toast?Personalized, real-time status Push
e.g. a friend achieves a new high score within a game we share
e.g. comments on my photo
Subscribed tailored content updates Pushe.g. ongoing sporting event scores e.g. breaking news
Application launch/usage Local / Push
e.g. update app tile to match more recent app content
e.g. clearing the unread mail count when mail is opened
Periodically for non-personalized content Periodice.g. every 30 minutes for stock or weather updates
Missed toast notifications Local / Push
e.g. missed phone calls in a VOIP app
www.buildwindows.com
How should I not update my tile?Avoid high frequency, streaming updatese.g. every minute to report a play-by-play sporting event e.g. real-time stock ticker on the tile
Do not clear the tile when the app launches/exitsLeave content on the tile to draw your user back to the app.It is okay to update the tile on app exit, however.
Do not update to explicitly replace ‘old content’Set the optional expiration on the tile at the time it is sent.
Only send new updates if there is new data to show the user.
Do not depend on tile orderingNotification queue tile display order is not guaranteed – “storyboards” will not work on tiles. Tile updates must be independent of one another.
• 11/1 4:15pm - Baker – Windows 8 Connectathon with Windows Azure Mobile Services (3-129)
Related sessions
• UX Guidelines – section on Tiles and Notifications
• Working with tiles, badges, and toast notifications
• App tiles and badges sample
• Secondary tiles sample
• Push and periodic notifications sample
• Raw notifications sample
• Lock screen apps sample
• Programming Windows 8 Apps in HTML, CSS, and JavaScript
Resources
Please submit session evals by using the Build Windows 8 appor at http://aka.ms/BuildSessions
• Develop: http://msdn.microsoft.com/en-US/windows/apps/br229512
• Design: http://design.windows.com/
• Samples: http://code.msdn.microsoft.com/windowsapps/Windows-8-Modern-Style-App-Samples
• Videos: http://channel9.msdn.com/Windows
Resources
Please submit session evals by using the Build Windows 8 appor at http://aka.ms/BuildSessions
© 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.