Understanding Microsoft Push Notifications for Windows Phone 7

The concept of push notifications (PN) is not new and is used by others in the industry. With that said, the Microsoft PN (MPN) service includes a cool twist that gives developers the power to create the impression that their application is always connected by displaying relevant information even while not running through the Live Tile displayed on the Start Screen. But before I dive into the guts of MPN, let’s explain what PNs are and why we need them.

To better understand PN, we need to remember that the end user experience is the first and foremost characteristic of Windows Phone (WP) design. A positive end-user experience is the number one WP design goal. This tenet has major implications for how WP works, not just in terms of its new UI and the interaction model it drives, but also with the application platform (the API for developers). Push notification is one obvious mechanism to ensure a coherent and deterministic end user behavior that allows you to communicate with the end user even when your phone application is not running on the phone.

The Windows Phone application model doesn’t allow you to write code that will run in the background while another application occupies the foreground (in other words, it does not allow 3rd party multitasking). But there are a growing number of “always connected application” scenarios that require background services to listen for changes and events. Come to think of it, most phone applications today have some network-related feature, whether updating scores and achievements in games, grabbing and displaying content from the cloud, or the latest trend, social applications.

The common denominator of all these scenarios is that each of them has a Web application or cloud service (we’ll use the term cloud services to include Web applications) that needs to communicate with the phone in order to notify the user that something of interest has happened. In general, if you want your application to be able to listen for updates and messages from the cloud, you have a few options. First, while your application is running in the foreground, you can poll the cloud service. Second, while your application is not in the foreground you can run a background service with a piece of code that will continue polling the cloud service and will awaken your application, bringing it back to the foreground when it’s needed.

What Is a Push Notification? For the developer, a PN message is a means to an end. Its main purpose is to trigger the user to launch your WP application. PN gives you the option to send messages in the form of notifications to a WP device, and even if your application is not running at the moment the message arrives, the message is handled by the WP for you and presented, most of the time, to the user in a predefined manner. PNs are an integral part of WP Shell and are integrated with the Quick Launch area of the phone’s Start experience (the main phone screen), and as an overlay on top of any running application (including any Shell screen). For the end user, PNs are a visual way for the phone to tap on the user’s shoulder saying – “Hey, something interesting just happened. Why don’t you take a look?” The user is unaware of how these messages arrive as long as they are displayed correctly and within the proper context.

A toast notification is displayed as an overlay message on the user’s current screen. This overlay is displayed on top of any given screen, including any running application, as long as it is not your application, and on top of any Shell screen. A toast notification is very interruptive, so as a developer you need to use it sparingly, making sure that the notification is important enough to warrant bothering the user, as the user always has the option to block all of your application’s notifications.

A tile is a visual, dynamic representation of an application or its content within the Quick Launch area of the phone’s Start experience. As you can see in the following image, there are multiple tiles. Some are square while others, like pictures, are bigger rectangles. The important thing to remember about tiles is that each tile has an icon and two strings associated with it. As a developer, if your application tile is pinned to the Start Screen, it means you can send a tile PN message, changing the content of your tile.

More by Author

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends & analysis

Must Read