Vous êtes sur la page 1sur 21

Andy Wigley | Microsoft Technical Evangelist

Rob Tiffany | Microsoft Enterprise Mobility Strategist

M8: Push Notifications
Target Agenda | Day 1
Module and Topic | 10-minute breaks after each session / 60-minute meal break
1a - Introducing Windows Phone 8 Application Development | Part 1 50:00
1b - Introducing Windows Phone 8 Application Development | Part 2 50:00
2 - Designing Windows Phone Apps 50:00
3 - Building Windows Phone Apps 50:00
4 - Files and Storage on Windows Phone 8 50:00
Meal Break | 60-minutes 60:00
5 - Windows Phone 8 Application Lifecycle 50:00
6 - Background Agents 25:00
7 - Tiles and Lock Screen Notifications 25:00
8 - Push Notifications 30:00
9 - Using Phone Resources on Windows Phone 8 50:00
Target Agenda | Day 2
Module and Topic | 10-minute breaks after each session / 60-minute meal break
10 - App to App Communication 35:00
11 - Network Communication on Windows Phone 8 50:00
12 - Proximity Sensors and Bluetooth 35:00
13 - Speech Input on Windows Phone 8 35:00
14 - Maps and Location on Windows Phone 8 35:00
15 - Wallet Support 25:00
16 - In App Purchasing 25:00
Meal Break | 60-minutes 60:00
17 - The Windows Phone Store 50:00
18 - Enterprise Applications in Windows Phone 8: Architecture and Publishing 50:00
19 - Windows 8 and Windows Phone 8 Cross Platform Development 50:00
20 Mobile Web 50:00
Push Notifications
Server-initiated Communication
Push Notifications Infrastructure
Three Kinds of Notifications : Raw, Toast and Tile
Push Response Headers
Module Agenda
Push Notifications and Live Tiles
Push Notifications offer developers a way to send timely
information relating to their applications even when they
are not running
Windows phone has the unique ability to provide the end
user glanceable access to the information they care most
about, via Live Tiles
Push Notifications
Server-initiated communication
Enable key background scenarios
Preserve battery life and user experience
Prevent polling for updates
Three Kinds of Notifications
Notification message content is application-specific
Delivered directly to app only if it is running
Specific XML schema
Content delivered to app if it is running
If app is not running, system displays Toast popup using notification message content
Specific XML schema
Never delivered to app
If the Tile is currently pinned to the Start screen, system updates it using notification message
Push Notification Data Flow
URI to the service:
Push enabled
the message
Push endpoint is established. URI is
created for the endpoint.
Send PN
Push Notification Features
Tile updates can update any display element of each of the Tile templates
Be careful to downgrade updates sent to 7.1 clients
30 subscription endpoints allowed per phone
Maximum size of a notification is 1KB for the header and 3KB for the payload.
Unauthenticated Web Service limited to 500 push notifications per subscription per day
Authenticated Web Services are recommended
Communication uses HTTPS channel
No limit
Able to register a callback request
Toast Message Content
Used by system to display Toast message if app not running
Navigates to page specified in <Param> (if supplied)
If app is already running
ShellToastNotificationReceived event fires
<Text1> and <Text2> values in event args as
Dictionary<string, string>

Toast Message Content
Use the following HTTP headers:

Where <batching interval> is 3 Immediate delivery, 13 delivered within 450 seconds, 23
delivered within 900 seconds

string toastMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<wp:Notification xmlns:wp=\"WPNotification\">" +
"<wp:Toast>" +
"<wp:Text1>WEATHER ALERT</wp:Text1>" +
"<wp:Text2>Stormy</wp:Text2>" +
"<wp:Param>/page1.xaml?value1=1234<wp:Param>" +
"</wp:Toast>" +
sendNotificationRequest.ContentType = "text/xml";
sendNotificationRequest.Headers.Add("X-WindowsPhone-Target", "toast");
sendNotificationRequest.Headers.Add("X-NotificationClass", "<batching interval>");
sendNotificationRequest.ContentType = "text/xml";
sendNotificationRequest.Headers.Add("X-WindowsPhone-Target", token");
sendNotificationRequest.Headers.Add("X-NotificationClass", "<batching interval>");
Tile Message Content
Tile messages are never delivered to the app
There are specific schemas for the a Tile update message for each of the three Tile Templates: Flip,
Cycle and Iconic
Only Tiles using Flip and Iconic templates can be updated with images at remote URLs
Remote Images limited to 80KB and must download in 30 seconds or less
V7.x clients cannot consume these new templates. Recommend you:
In your app, capture the device unique ID, the push URI, the OS version and the app
version. Send this data to your Web service registration method
Make sure you only send the new templates to compatible new OS versions/app versions!
Use the following HTTP headers:
FlipTile Template Tile Message Schema
<?xml version="1.0"?>
<wp:Notification xmlns:wp="WPNotification" Version="2.0">
<wp:Tile Id="[TileId]" Template="FlipTile">
<wp:SmallBackgroundImage Action="Clear">[sm tile img URI]</wp:SmallBackgroundImage>
<wp:WideBackgroundImage Action="Clear">[front of wd tile img URI]</wp:WideBackgroundImage>
<wp:WideBackBackgroundImage Action="Clear">[back of wd tile img URI]</wp:WideBackBackgroundImage>
<wp:WideBackContent Action="Clear">[back of wd tile content text]</wp:WideBackContent>
<wp:BackgroundImage Action="Clear">[front of med tile img URI]</wp:BackgroundImage>
<wp:Count Action="Clear">[count]</wp:Count>
<wp:Title Action="Clear">[title text]</wp:Title>
<wp:BackBackgroundImage Action="Clear">[back of med tile img URI]</wp:BackBackgroundImage>
<wp:BackTitle Action="Clear">[back of tile title text]</wp:BackTitle>
<wp:BackContent Action="Clear">[back of med tile content text]</wp:BackContent>

CycleTile Template Tile Message Schema
<?xml version="1.0"?>
<wp:Notification xmlns:wp="WPNotification" Version="2.0">
<wp:Tile Id="[TileId]" Template="CycleTile">
<wp:SmallBackgroundImage Action="Clear">[sm tile img URI]</wp:SmallBackgroundImage>
<wp:CycleImage1 Action="Clear">[photo 1 img URI]</wp:CycleImage1>
<wp:CycleImage2 Action="Clear">[photo 2 img URI]</wp:CycleImage2>
<wp:CycleImage3 Action="Clear">[photo 3 img URI]</wp:CycleImage3>
<wp:CycleImage4 Action="Clear">[photo 4 img URI]</wp:CycleImage4>
<wp:CycleImage5 Action="Clear">[photo 5 img URI]</wp:CycleImage5>
<wp:CycleImage6 Action="Clear">[photo 6 img URI]</wp:CycleImage6>
<wp:CycleImage7 Action="Clear">[photo 7 img URI]</wp:CycleImage7>
<wp:CycleImage8 Action="Clear">[photo 8 img URI]</wp:CycleImage8>
<wp:CycleImage9 Action="Clear">[photo 9 img URI]</wp:CycleImage9>
<wp:Count Action="Clear">[count]</wp:Count>
<wp:Title Action="Clear">[title text]</wp:Title>
IconicTile Template Tile Message Schema
<?xml version="1.0"?>
<wp:Notification xmlns:wp="WPNotification" Version="2.0">
<wp:Tile Id="[TileId]" Template="IconicTile">
<wp:SmallIconImage Action="Clear">[sm icon img URI]</wp:SmallIconImage>
<wp:IconImage Action="Clear">[med/wd icon img URI]</wp:IconImage>
<wp:WideContent1 Action="Clear">[wd tile content line 1]</wp:WideContent1>
<wp:WideContent2 Action="Clear">[wd tile content line 2]</wp:WideContent2>
<wp:WideContent3 Action="Clear">[wd tile content line 3]</wp:WideContent3>
<wp:Count Action="Clear">[count]</wp:Count>
<wp:Title Action="Clear">[title text]</wp:Title>
<wp:BackgroundColor Action="Clear">[hex ARGB background color of tile]</wp:BackgroundColor>
Raw Message Content
Use the following HTTP headers:

Where <batching interval> is 3 Immediate delivery, 13 delivered within 450 seconds, 23
delivered within 900 seconds
Message Content is application-specific only gets delivered to running app
For example use XML to format data

string tileMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
"<root>" +
"<Value1>SomeUserValue<Value1>" +
"<Value2>SomeOtherUserValue<Value2>" +
sendNotificationRequest.ContentType = "text/xml";
sendNotificationRequest.Headers.Add("X-NotificationClass", "<batching interval>");
Push Notifications
Response Custom Headers
Response Code: HTTP status code (200 OK)
Notification Status
Notification received by the Push Notification Service
For example: X-NotificationStatus:Received
The connection status of the device
//For example: X-DeviceConnectionStatus:Connected
The subscription status
//For example: X-SubscriptionStatus:Active
More information
Push Notifications are an efficient and battery-friendly way of sending notifications
from a server to an app on a phone
Raw notifications go only to a running app
Toast notifications go to the app if it is running, otherwise display as a popup on
the phone
Tile notifications are used only to update tiles on the Start Screen
The information herein is for informational
purposes only an 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.
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.