techdays 2012 - windows phone push notifications & life tiles
DESCRIPTION
Developer presentation on implementing push notifications and life tiles to your Windows Phone applicationsTRANSCRIPT
![Page 1: Techdays 2012 - Windows Phone Push notifications & Life tiles](https://reader035.vdocuments.us/reader035/viewer/2022062513/5560b57cd8b42afe3b8b49a4/html5/thumbnails/1.jpg)
![Page 2: Techdays 2012 - Windows Phone Push notifications & Life tiles](https://reader035.vdocuments.us/reader035/viewer/2022062513/5560b57cd8b42afe3b8b49a4/html5/thumbnails/2.jpg)
Push notifications, live tiles and background agentsfor Windows Phone 7
Geert van der CruijsenConsultant – Avanade
@geertvdchttp://vdcruijsen.net
![Page 3: Techdays 2012 - Windows Phone Push notifications & Life tiles](https://reader035.vdocuments.us/reader035/viewer/2022062513/5560b57cd8b42afe3b8b49a4/html5/thumbnails/3.jpg)
Make your App come alive with
push notificationsand live tiles
![Page 4: Techdays 2012 - Windows Phone Push notifications & Life tiles](https://reader035.vdocuments.us/reader035/viewer/2022062513/5560b57cd8b42afe3b8b49a4/html5/thumbnails/4.jpg)
Push notificationsTileIf tile is pinned tile will be updatedApplication not accessed
ToastData delivered to app when app is runningToast popup if app is not running
RawOnly delivered when app is runningContent handled by application
![Page 5: Techdays 2012 - Windows Phone Push notifications & Life tiles](https://reader035.vdocuments.us/reader035/viewer/2022062513/5560b57cd8b42afe3b8b49a4/html5/thumbnails/5.jpg)
Architecture
Microsoft Push Notification Server
Cloud App Service
Push Client Service
Push enabled Application
Request push URI
Push client/server negotiation
Register URI at App service
Push message
Push message
![Page 6: Techdays 2012 - Windows Phone Push notifications & Life tiles](https://reader035.vdocuments.us/reader035/viewer/2022062513/5560b57cd8b42afe3b8b49a4/html5/thumbnails/6.jpg)
Even when he’s not using your app
Notifythe user
![Page 7: Techdays 2012 - Windows Phone Push notifications & Life tiles](https://reader035.vdocuments.us/reader035/viewer/2022062513/5560b57cd8b42afe3b8b49a4/html5/thumbnails/7.jpg)
Scenarios
WeatherGamesSportsMessagingNewsUtilities
![Page 8: Techdays 2012 - Windows Phone Push notifications & Life tiles](https://reader035.vdocuments.us/reader035/viewer/2022062513/5560b57cd8b42afe3b8b49a4/html5/thumbnails/8.jpg)
Building the Phone partAsk for user permissionNot being able to disable push notifications will fail marketplace certification
Register Phone with Push Service
Register Event Handlers
Handle optional in app notificationsRaw notifications
In app toast notifications
![Page 9: Techdays 2012 - Windows Phone Push notifications & Life tiles](https://reader035.vdocuments.us/reader035/viewer/2022062513/5560b57cd8b42afe3b8b49a4/html5/thumbnails/9.jpg)
DemoBuilding the Phone Part
![Page 10: Techdays 2012 - Windows Phone Push notifications & Life tiles](https://reader035.vdocuments.us/reader035/viewer/2022062513/5560b57cd8b42afe3b8b49a4/html5/thumbnails/10.jpg)
Building the ServiceRegister PhoneUnique IDURI
Update Phone URI
Send Notifications
Handle return codes
![Page 11: Techdays 2012 - Windows Phone Push notifications & Life tiles](https://reader035.vdocuments.us/reader035/viewer/2022062513/5560b57cd8b42afe3b8b49a4/html5/thumbnails/11.jpg)
DemoBuilding the Service Part
![Page 12: Techdays 2012 - Windows Phone Push notifications & Life tiles](https://reader035.vdocuments.us/reader035/viewer/2022062513/5560b57cd8b42afe3b8b49a4/html5/thumbnails/12.jpg)
Phone APIPinning tiles
ShellTileUpdateprivate void CreateTileSchedule(){ schedule = new ShellTileSchedule(); schedule.Interval = UpdateInterval.EveryDay; schedule.MaxUpdateCount = 7; schedule.Recurrence = UpdateRecurrence.Interval; schedule.RemoteImageUri = new Uri(@"http://www.server.com/image.png"); schedule.Start();}
![Page 13: Techdays 2012 - Windows Phone Push notifications & Life tiles](https://reader035.vdocuments.us/reader035/viewer/2022062513/5560b57cd8b42afe3b8b49a4/html5/thumbnails/13.jpg)
DemoGenerating dynamic local tile images
![Page 14: Techdays 2012 - Windows Phone Push notifications & Life tiles](https://reader035.vdocuments.us/reader035/viewer/2022062513/5560b57cd8b42afe3b8b49a4/html5/thumbnails/14.jpg)
Service XML messagesTile notifications<wp:Notification xmlns:wp="WPNotification">
<wp:Tile Id="/SessionPage.xaml?id=0">
<wp:BackgroundImage>http://www.server.com/background.png</wp:BackgroundImage>
<wp:Count>12</wp:Count>
<wp:Title>Techdays App</wp:Title>
<wp:BackBackgroundImage>http://www.server.com/backbackground.png</wp:BackBackgroundImage>
<wp:BackContent>PushNotification session</wp:BackContent>
<wp:BackTitle>Geert van der Cruijsen</wp:BackTitle>
</wp:Tile>
</wp:Notification>
![Page 15: Techdays 2012 - Windows Phone Push notifications & Life tiles](https://reader035.vdocuments.us/reader035/viewer/2022062513/5560b57cd8b42afe3b8b49a4/html5/thumbnails/15.jpg)
Service XML messagesToast notifications<wp:Notification xmlns:wp="WPNotification">
<wp:Toast>
<wp:Text1>Techdays2012</wp:Text1>
<wp:Text2>Next session starts in 5 minutes</wp:Text2>
<wp:Param>/SessionPage.xaml?id=1</wp:Param>
</wp:Toast>
</wp:Notification>
![Page 16: Techdays 2012 - Windows Phone Push notifications & Life tiles](https://reader035.vdocuments.us/reader035/viewer/2022062513/5560b57cd8b42afe3b8b49a4/html5/thumbnails/16.jpg)
Tips & TricksUser Opt-in
Check device capabilities<Capability Name="ID_CAP_PUSH_NOTIFICATION"/> <Capability Name="ID_CAP_IDENTITY_DEVICE"/>
Encrypt channel URI
Tiles max 80kb and 15 seconds
![Page 17: Techdays 2012 - Windows Phone Push notifications & Life tiles](https://reader035.vdocuments.us/reader035/viewer/2022062513/5560b57cd8b42afe3b8b49a4/html5/thumbnails/17.jpg)
Tips & TricksPower managementCriticalLowPowerLevel – No push messages will be sentLowPowerLevel – only Raw push messages will be sentNormalPowerLevel – All push messages will be sent
MPNS http response codes200 OK – Received, Suspended, QueueFull400 Bad Request – Error in your xml404 Not Found – Subscription not valid. Stop sending406 Not acceptable – Maximum of 500 messages reached412 Preconditions failed – Phone inactive. Resend max 1x per hour
![Page 18: Techdays 2012 - Windows Phone Push notifications & Life tiles](https://reader035.vdocuments.us/reader035/viewer/2022062513/5560b57cd8b42afe3b8b49a4/html5/thumbnails/18.jpg)
Background agentsPeriodicTaskRecurring task on regular intervalMax every 30 minutesMaximum of 6 background agents per device
ResourceIntensiveTaskSingle task that can run for a longer time when specific requirements are met
![Page 19: Techdays 2012 - Windows Phone Push notifications & Life tiles](https://reader035.vdocuments.us/reader035/viewer/2022062513/5560b57cd8b42afe3b8b49a4/html5/thumbnails/19.jpg)
PeriodicTaskUnsupported APIsUICamera
Memory restrictions6 MB / 15 MB
Reschedule every 2 weeksUnscheduled after 2 consecutive crashes
![Page 20: Techdays 2012 - Windows Phone Push notifications & Life tiles](https://reader035.vdocuments.us/reader035/viewer/2022062513/5560b57cd8b42afe3b8b49a4/html5/thumbnails/20.jpg)
PeriodicTask Typical APIsGeoCoordinateWatcher
HttpWebRequest
Mutex
ShellToast
ShellTile
![Page 21: Techdays 2012 - Windows Phone Push notifications & Life tiles](https://reader035.vdocuments.us/reader035/viewer/2022062513/5560b57cd8b42afe3b8b49a4/html5/thumbnails/21.jpg)
ResourceIntensiveTaskHeavy requirementsMax duration of 10 minutesExternal power requiredNon cellular internet connection requiredBattery power needs to be 90% or higherScreen needs to be locked
![Page 22: Techdays 2012 - Windows Phone Push notifications & Life tiles](https://reader035.vdocuments.us/reader035/viewer/2022062513/5560b57cd8b42afe3b8b49a4/html5/thumbnails/22.jpg)
DemoBuilding a background agent
![Page 23: Techdays 2012 - Windows Phone Push notifications & Life tiles](https://reader035.vdocuments.us/reader035/viewer/2022062513/5560b57cd8b42afe3b8b49a4/html5/thumbnails/23.jpg)
ResourcesPush Notification Helper Libraryhttp://windowsteamblog.com/windows_phone/b/wpdev/archive/2011/01/14/windows-push-notification-server-side-helper-library.aspx
Azure toolkithttp://watoolkitwp7.codeplex.com/
Windows Phone App hubhttp://create.msdn.com
#wp7nl
![Page 24: Techdays 2012 - Windows Phone Push notifications & Life tiles](https://reader035.vdocuments.us/reader035/viewer/2022062513/5560b57cd8b42afe3b8b49a4/html5/thumbnails/24.jpg)
Call to actionStart building Windows Phone apps!
Include Push notifications and/or live tiles!Multiple local tilesPush is not hard!
![Page 25: Techdays 2012 - Windows Phone Push notifications & Life tiles](https://reader035.vdocuments.us/reader035/viewer/2022062513/5560b57cd8b42afe3b8b49a4/html5/thumbnails/25.jpg)
Q&A
@geertvdchttp://vdcruijsen.net