Andy Wigley APPA Mundi Microsoft Windows Phone Development MVP

Post on 24-Feb-2016

29 Views

Category:

Documents

1 Downloads

Preview:

Click to see full reader

DESCRIPTION

Push Notification Services. Andy Wigley APPA Mundi Microsoft Windows Phone Development MVP. http:// mobileworld.appamundi.com/blogs/andywigley/rss.aspx. andy.wigley@appamundi.com. Push Notifications. Server-initiated Communication. - PowerPoint PPT Presentation

Transcript

ONLINE CONFERENCE

DESIGN.BUILD.DELIVERwith WINDOWS PHONE

THURSDAY 24 MARCH 2011

Andy WigleyAPPA MundiMicrosoft Windows Phone Development MVP

http://mobileworld.appamundi.com/blogs/andywigley/rss.aspx

andy.wigley@appamundi.com

Push Notification Services

Server-initiated Communication

Push Notifications

Your web service sends messages to phones where your push notification-enabled app is installed

• Server-initiated so app does not have to poll server• Battery friendly• Provide alerts in the app, toast popup alerts or live

tile updates

• Provide a real-time data feed capability to your app• Enhance user experience

4

Live Tiles

• Shortcuts to apps

• Static or dynamic

• 2 sizes: small & large

• “Pin to Start”

5

Notification Toasts

Interruptive, transient and chase-able App icon + 2 text fields

Time critical and personally relevant Users must opt-in via app UI

Raw Notifications• Notification message

content is application-specific

• Delivered directly to app only if it is running

• How you use the message content is application-specific

7

Three Kinds of Notifications• Tile

– Specific XML schema– Never delivered to app – If user has pinned app tile to Start screen, system

updates it using notification message content• Toast

– Specific XML schema– Content delivered to app if it is running– If app is not running, system displays Toast popup

using notification message content• Raw

– Notification message content is application-specific– Delivered directly to app only if it is running

Push Notification Data Flow

8

URI to the service:"http://notify.live.com/throttledthirdparty/01.00/AAF

RQHgiiMWNTYrRDXAHQtz-AgrNpzcDAwAAAAQOMDAwMDAwMDAwMDAwMDA"Push enabled

application

Notifications service HTTP POST the

message

Push endpoint is established. URI is created for the endpoint.

1

2

3

3rd party service

Microsofthosted server

Send PN Message

4

9

Raw Message Content• Message Content is application-specific – only gets delivered

to running app• For example use XML to format data

private static byte[] prepareRAWPayload(string location, string temperature, string weatherType){ MemoryStream stream = new MemoryStream(); XmlWriterSettings settings = new XmlWriterSettings() { Indent = true, Encoding = Encoding.UTF8 }; XmlWriter writer = XmlTextWriter.Create(stream, settings);

writer.WriteStartDocument(); writer.WriteStartElement("WeatherUpdate");

writer.WriteStartElement("Location"); writer.WriteValue(location); writer.WriteEndElement();... writer.WriteEndElement(); writer.WriteEndDocument(); writer.Close();

byte[] payload = stream.ToArray(); return payload;}

10

Toast Message Contentstring toastMessage ="<?xml version=\"1.0\" encoding=\"utf-8\"?>" +"<wp:Notification xmlns:wp=\"WPNotification\">" + "<wp:Toast>" + "<wp:Text1><string></wp:Text1>" + "<wp:Text2><string></wp:Text2>" + "</wp:Toast>" +"</wp:Notification>";

Used by system to display Toast message if app not running

ShellToastNotificationReceived event fires if app is running <Text1> and <Text2> values in

event args as Dictionary<string, string>

11

Tile Message Contentstring tileMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +"<wp:Notification xmlns:wp=\"WPNotification\">" + "<wp:Tile>" + "<wp:BackgroundImage><background image path></wp:BackgroundImage>" + "<wp:Count><count></wp:Count>" + "<wp:Title><title></wp:Title>" + "</wp:Tile> " +"</wp:Notification>";

Never delivered to app <background image path>, <count>, and <title>

are in a string format Maximum allowed size of the tile image referenced

in <background image path> is 80 KB, with a maximum download time of 1 minute

Server Side Helper Recipe

13

Building a Push Notification Service

Using the Push Notification Server-Side Helper Library

Demo

Response Custom Headers• Response Code: HTTP status code (200 OK)• Notification Status

– Notification received by the Push Notification Service– For example: “X-NotificationStatus:Received”

• DeviceConnectionStatus– The connection status of the device– //For example: X-DeviceConnectionStatus:Connected

• SubscriptionStatus– The subscription status– //For example: X-SubscriptionStatus:Active

• More information – http://msdn.microsoft.com/en-us/library/ff402545(v=VS.

92).aspx

15

Tile Schedule• Periodically updates the tile image without

requiring a Push Notification message• Updates images only from the web, not

from the app local store• Few limitations

– Image size must be less than 80 KB– Download time must not exceed 60 seconds– Lowest update time resolution is up to 60

minutes

16

Scheduling Tile Updatepublic partial class MainPage : PhoneApplicationPage {    private ShellTileSchedule _mySchedule;    public MainPage()   {        InitializeComponent();        ScheduleTile();    }

     private void ScheduleTile()    {        _mySchedule = new ShellTileSchedule();        _mySchedule.Recurrence = UpdateRecurrence.Onetime;        _mySchedule.StartTime = DateTime.Now;        _mySchedule.RemoteImageUri = new Uri("http://cdn3.afterdawn.fi/news/small/windows-phone-7-series.png");        _mySchedule.Start();    }}

Thank You for attending today’s Tech.Days Online Conference.

Today’s Online Conference will be recorded. It will be made available on-demand very soon.

Your Feedback Matters! Please complete the online evaluation form which will be emailed to you.

© 2008 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.

ONLINE CONFERENCE

top related