1 / 18

Andy Wigley APPA Mundi Microsoft Windows Phone Development MVP

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.

berg
Download Presentation

Andy Wigley APPA Mundi Microsoft Windows Phone Development MVP

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Push Notification Services Andy Wigley APPA Mundi Microsoft Windows Phone Development MVP http://mobileworld.appamundi.com/blogs/andywigley/rss.aspx andy.wigley@appamundi.com

  2. Push Notifications Server-initiated Communication • 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

  3. Live Tiles • Shortcuts to apps • Static or dynamic • 2 sizes: small & large • “Pin to Start”

  4. Notification Toasts App icon + 2 text fields Interruptive, transient and chase-able Time critical and personally relevant Users must opt-in via app UI

  5. 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

  6. 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

  7. Push Notification Data Flow 2 URI to the service: "http://notify.live.com/throttledthirdparty/01.00/AAFRQHgiiMWNTYrRDXAHQtz-AgrNpzcDAwAAAAQOMDAwMDAwMDAwMDAwMDA" 3rd party service Push enabled application 3 Notifications service HTTP POST the message 4 Send PN Message 1 Microsoft hosted server Push endpoint is established. URI is created for the endpoint.

  8. RawMessage 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; • }

  9. string toastMessage= "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<wp:Notificationxmlns:wp=\"WPNotification\">" + "<wp:Toast>" + "<wp:Text1><string></wp:Text1>" + "<wp:Text2><string></wp:Text2>" + "</wp:Toast>" + "</wp:Notification>"; Toast Message Content • 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>

  10. string tileMessage = "<?xml version=\"1.0\" encoding=\"utf-8\"?>" + "<wp:Notificationxmlns: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>"; Tile Message Content • 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

  11. Server Side Helper Recipe

  12. Building a Push Notification Service Demo Using the Push Notification Server-Side Helper Library

  13. 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

  14. 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

  15. Scheduling Tile Update • public 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(); •     } • }

  16. 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.

More Related