Windows Phone 7 Push Notifications For Beginners (Now With Testing!)

I know there are about a thousand blog posts on implementing push notifications in a Windows Phone 7 application. But having now implemented push notifications a couple times into WP7 projects, I felt like something was missing from the community knowledge base. So, in order to try to cover WP7 Push notifications for the uninitiated, I’m putting together a set of posts will try to cover the following topics:

  1. Windows Phone 7 Push Notifications (10,000 Foot View)
  2. Implementing Push Notifications on a Device (with Project code)
  3. Testing Push Notifications On My Device Without Writing a Goddamn Web Service (Also, How To Write A WP7 Push Service in PHP)

Windows Phone 7 Push Notifications (10,000 Foot View)

The Windows Phone 7 push notification is actually an extremely elegant way of doing push notifications. Personally, I love it. I’ll walk through the steps conceptually here and then mirror the steps in the code post.

(Note to experts: I may be getting some of the details about how this works in the underlying architecture wrong. However, this is how it seems to me that it works and it makes sense this way.)

Step 1: Say “Hey, phone! I want to send you push notifications about some stuff.” When you do this, you’re doing it with a couple of conditions. The first is that you’re giving your specific push service a name (like “Bob” but hopefully a little more specific).

Next, you’ll need to determine if you want to use the “Toast” notification or the “Tile” notification or the “Raw” notification or some combination of these three. When you know what kind of notifications you want, you’ll basically write a magic piece of code which communicates to the magical push notification fairy, who, in return for your good deeds, gives you a device/application specific URL that you will use to send notifications to your phone.


You think I’m kidding. I’m not. As a preview, the code you need to write is: “myPushStuff.Open()”. And that’s it. Then you just wait for the magical push notification fairy to give you the URL you’ll use to send notifications to your phone.

You don’t actually need to send information about toast and tile to the push registration service. However, if you decide later on thatyou actually wanted to send a toast notifications, not a tile notification, your old URL won’t work… you’ll need to save a new one. Don’t know why or how exactly this happens… just passing along helpful information.

If you’re looking for information about the difference between tile, toast and raw notifications, the image below was stolen from the msdn article that talks about the differences. Go read about it there… I won’t stoop to copying and pasting all their excellent information into my blog post.


Step 2: Once you have your magical URL, save it in such a way that whatever webservice you’re using can recognize which phone it’s tied to. Maybe you’re saving it along with a username or with a zip code (like with a weather service). In any case, you’ll want to be able to send the right push notifications to the right phones.

When the time comes to send the notification, your webservice will need to send an XML chunk created for your notification (see details here) to the phone-specific URL. Then, the Microsoft Push Notification Service handles your push request and forwards it to the phone, sending a response telling you that it worked (or didn’t work).


I’ve got my gripes with Windows Phone 7, but the push notification implementation ain’t one of them. It’s very straightforward and can be implemented on the phone with very little code and on a server with similar ease. If you’re a newbie mobile developer and this looks complicated, go try to implement push notification on Android or iOS. For all you Android and iOS people out there I would like to say:


The next post will walk through the steps to register your app for push notifications. I’ll post a link to it in this post when I get it up.

5 thoughts on “Windows Phone 7 Push Notifications For Beginners (Now With Testing!)

  1. I see you share interesting stuff here, you can earn some extra cash,
    your blog has huge potential, for the monetizing method, just type in google – K2 advices how to monetize a

  2. Hi,
    Great blog!! I have an isusue with MPNS push service.
    I have written a small application which gives in the ChannelurI.
    Using this channeluri i am trying to push from the rest client.
    But i get 400 bad request.
    Can you please help me.


  3. Hi @all. I like your blog and also you do not wrote something about writing a WP7 Push Service in PHP yet, I have a question to this point because I have actualy a Problem with it…. It would be very nice if you can help me out a little bit 🙂

    I am getting this answer from the Microsoft Push Notification Service:…….
    HTTP/1.1 200 OK Cache-Control: private Server: Microsoft-IIS/7.5 X-DeviceConnectionStatus: Connected X-NotificationStatus: Received X-SubscriptionStatus: Active X-MessageID: 00000000-0000-0000-0000-000000000000 ActivityId: fbef32c2-4785-4b52-a492-45f1e38fc635 X-Server: DB3MPNSM006 X-AspNet-Version: 4.0.30319 X-Powered-By: ASP.NET Date: Thu, 12 May 2011 08:25:38 GMT Content-Length: 0

    But my App is not getting the Notification and the channel is closed every time I try this. If you like to the the script I can send it to an email address or post it here.

    Best regards

Comments are closed.