The Windows Phone 7 platform provides developers with three types of push notifications: toast notifications, tile notifications, and raw
notifications. All three types follow the same basic principles of
operation and processing, yet differ in the way they display
notifications. Toast and tile notification types are used only when the
application is not running; raw notifications are used to continuously
receive messages while the application is running in the foreground.
Let's discuss each notification type in detail.
1. Toast Notifications
Toast notifications are
displayed as overlays at the top of a phone's screen. Only a message
title and a line of text can be controlled by the service or an
application sending ("pushing") a toast notification; the icon that
appears on the left side of a toast notification is the default icon for
the application deployed on the Windows Phone 7 device. You can display
toast notifications only when an application is not running; if an
application is running when a toast notification is sent, it is not
displayed on the phone screen.
Toast notifications are used to display information that is timely and urgent. An example of toast notification is shown in Figure 1,
where it appears as "Time to buy..." text at the top of the phone
screen. Here, a notification has been received about Microsoft stock
becoming an attractive buy. If the user chooses to tap (or click) the
toast notification, an application opens up, allowing users to take
additional actions within the application.
2. Tile Notifications
Tile notifications can
alter the contents of any application tile that is pinned to the Quick
Launch area of the phone initial screen (also referred to as Start
Experience/Start Screen in Microsoft documentation). Tile notifications
are used to communicate information visually, by displaying, say, dark
clouds with rain to represent a rapidly approaching storm. Generally, an
application tile is a visual representation of an application and its
contents or functionality. An application tile typically contains an
icon and two strings, and tile notifications can change any of these
elements, as well as the background of each tile. To change a tile's
background image, a tile notification must include a URI that points to
the new image, a URI that can be either local or cloud-based. The string
at the bottom of an application tile is referred to as the tile title. The string in the middle and slightly to the right is referred to as the tile counter.
3. Raw Notifications
The third and final type of
push notification is the raw notification, which can be used to
continuously send messages or updates to a Windows Phone 7 application
that is running in the foreground. Contrast this with toast and tile
notifications, which are used to send updates to an application when it
is not running front and center on the Windows Phone 7 device. Unlike
toast and tile notifications, all raw notifications are dropped once an
application is no longer running in the foreground on the Windows Phone 7
device. Raw notifications are an energy-friendly alternative to
constantly polling web services for data; this type of push notification
also eliminates the need to keep connections to web services open for
prolonged periods of time.
Each notification type has its
"niche," so to speak, or the specific application development scenarios
it shines with more than the others. For instance, if an application
receives updates only when it's actively used, such as a chat
application, then a raw notification is the most appropriate mechanism
for transmitting these updates. If an application is ideally suited to
communicate updates via the use of visual elements on an ongoing basis,
such as weather updates, sports events scores, or stock prices, tile
applications are a more appropriate choice. Finally, if text-based
messages are the most appropriate form of communication on an
around-the-clock basis, such as e-mail receipts, Facebook friend
requests, or news alerts, toast notifications would be most suitable.
Having taken a look
at three available push notification types, let's turn our attention to
the architecture of notification services, since knowing the
architecture will help you better understand how to program and
troubleshoot push notification services.
Table 1. Characteristics of Windows Phone Push Notification Types
PN Type | Must Application Be Running in Foreground? | Must Application Tile be Pinned to Start Screen? | Use |
---|
Toast | No | No | Urgent and time-sensitive data (e.g., storm warning) |
Tile | No | Yes | Updates (e.g., count of new messages) |
Raw | Yes | No | Continuous data (e.g., Twitter client, stock ticker) |