The Microsoft Push Notification Service in Windows Phone offers third party developers a resilient, dedicated, and persistent channel to send information and updates to a Windows Phone application from their web sites (web services).
In the past, a mobile application would need to frequently poll its corresponding web service to know if there are any pending notifications. While effective, polling results in the device radio being frequently turned on, impacting battery life in a negative way. By using push notifications instead of polling, a web service can notify an application of important updates on an as-needed basis.
When a web service has information to send to an application, it sends a push notification to the Push Notification Service, which in turn routes the push notification to the application. Depending on the format of the push notification and the payload attached to it, the information is delivered as raw data to the application, the application's tile is visually updated, or a toast notification is displayed. The application can then contact the web service using its own protocol, if needed.
The Push Notification Service sends a response code to your web service after a push notification is sent. However, the Push Notification Service does not provide an end-to-end confirmation that your push notification was delivered from your web service to your application. For more information, see Push Notification Service Response Codes for Windows Phone
This lab covers the push notification and also introduces the usage of http services in Silverlight. During this lab you will create server side logic needed to send messages through Push Notification Service. You will create a simple Windows Phone 7 application which serves as a client to receive such notifications. The client application will receive weather updates. The server side business application (simple WPF application) will send weather alerts to registered client applications through Push Notification Services. Once client Windows Phone 7 application will receive such alert it will display received information.
Note, the server side Weather application uses the WindowsPhone.Recipes.Push.Messasges.dll which encapsulate all the logic and functionality for sending and receiving responses from Microsoft Push Notification Services.
At the end of the lab you will:
The following is required to complete this hands-on lab:
For convenience, much of the code used in this hands-on lab is available as Visual Studio code snippets. To install the code snippets:
Using the Code Snippets
With code snippets, you have all the code you need at your fingertips. The lab document will tell you exactly when you can use them. For example,
Using Visual Studio code snippets to insert code into your project
To add this code snippet in Visual Studio, you simply place the cursor where you would like the code to be inserted, start typing the snippet name (without spaces or hyphens), watch as IntelliSense picks up the snippet name, and then press the Tab key twice when the snippet you want is selected. The code will be inserted at the cursor location.
Start typing the snippet name
Press Tab to select the highlighted snippet
Press Tab again to expand the snippet
To insert a code snippet using the mouse rather than the keyboard, right-click where you want to insert the code snippet, select Insert Snippet followed by My Code Snippets and then pick the relevant snippet from the list.
To learn more about Visual Studio IntelliSense Code Snippets, including how to create your own, see http://msdn.microsoft.com/en-us/library/ms165392.aspx.
This hands-on lab comprises the following exercises:
Estimated time to complete this lab: 90 minutes.