May 24, 2011

Mango introduces some changes in Push Notifications mechanism which enables the developers to create more attractive scenarios.

First feature I’ll show in this post is a secondary tiles for application. Before Mango, every application could have only one pinned tile on the main screen which could be updated using Push Notification mechanism (I blogged about it quite some time ago here and here).

Mango release enables to have additional tiles which can be pinned and removed from application code! How about having something like this:

All the tiles (beside IE9) on main screen are related to sample I’m going to show here… And they are flipping randomly! Clicking on the tile will take us directly to the person’s mood page:

The UI of the app will be very simple – only a bunch of checkboxes to create/remove secondary tiles:

Checking the checkbox will add corresponding secondary tile to the main screen; unchecking the checkbox will remove it.

Let’s see what’s new in those methods. First – StandardTileData. It is a new class which defines the behavior of the secondary tile. It enables to define titles, contents and images for both sides of the tile. It also enables setting the count property to front face of the tile.

Note: If back property was not set, the tile will not flip.

Next – creating the tile itself: ShellTile.Create accepts the URI parameter which will serve two purposes: the ID of the tile and the URI within the application to navigate if the tile clicked.

Those parameters also affect the tile notification format sent to the application through Push Notification Server:

Note #2: the application doesn’t need to have primary tile on the main screen in order to make secondary tile to work.

Since it is not possible to create two tiles with the same ID, we need to manage the tiles from the application. For this matters ShellTile class provides the collection of ActiveTiles which represent all pinned tiles of the application (including the main tile if pinned by user).

The sample checks the pinned stated for secondary tiles and sets the corresponding checkbox state:

This way tiles added and removed from the main screen. See the video of working application below:

Working application

Last feature I want to talk about is known as “deep toast”. It enables to send relative URI to the application and navigate to specific page when TOAST notification clicked by user. In addition I’ll show how to send a local push notification message.

First – the change you have to make for your server side logic to sent deep toast message via push notification server: