Mike Taulty's Blog
Bits and Bytes from Microsoft UK
Windows 8 Metro Style App – Simple WNS Push Notification


Mike Taulty's Blog



I’ve been asked a couple of times about this so I thought I’d write up a simple way in which you can deliver a push notification to a Windows 8 Metro style app for testing purposes. There are other/better ways involving the Windows Azure Toolkit which would give you a lot more but here’s a simple way of getting started.

Firstly, if you’re not involved in an application that’s in the Store then you need to go and visit the following site to register the app;


This is well documented on the site but you need to setup a new app by copying from your project’s application manifest;


onto the web page;


The page then comes back with 3 pieces of information which I’ve scribbled on a little in the picture below;


You take the top one of these and drop it back into your package manifest;


Now you need some code in order to have a channel URI for receiving notifications. Here’s the most basic JS code I could come up with to set that up;

       var PushNotifications = Windows.Networking.PushNotifications;
        var promise = PushNotifications.PushNotificationChannelManager.createPushNotificationChannelForApplicationAsync();

            function (channel)

that then gives you a URI and along with the previously obtained “Package Security Identifier (SID)” and “Client Secret” that’s all I need to contact the Windows Notification Service and send a notification.

The details of how to do that are documented here but what I’ve tended to do is to make use of a simple WPF app that I put together months ago purely for testing this out. I’ll include the source code for it at the end of the post. It was put together very quickly in the past.

The app looks like this;


Sure it’s a mess :-) but the basic idea is;

  1. Paste in your client ID from the website.
  2. Paste in your Client Secret from the website.
  3. Hit TAB to make sure that you lose focus (sorry!) and hit the “Authenticate” button.
  4. Paste in the notification URL that your code got when it ran and got a URL.
  5. Set the type of notification that you want.
  6. Change the XML data if you like.
  7. Hit the “Notify Metro App” button.

And that’s works for me. Naturally, in the real world you wouldn’t notify your users by asking them to send you all of their channel URI’s on a daily basis and then pasting them into this app – you’d use some kind of service that can talk to the WNS service but then you know this already :-)

Here’s the bits of the WPF app for download – buyer beware on this one as it was put together in a hurry a while ago.


Posted Fri, Jun 8 2012 4:40 PM by mtaulty
Filed under:


Peter Kellner wrote re: Windows 8 Metro Style App – Simple WNS Push Notification
on Fri, Jul 20 2012 4:50 PM

very helpful!  thanks.  I actually got through all this and even after pressing the "Notify Metro App", I got a message that says "*Seemed* to wokr :-)".  I have to admit though I'm looking for the rest of the story here.  

1) What worked?

2) Who generated that messagebox?

3) How does my metro app subscribe to that message?

BTW, I'm running on win8RC

Finally, just a reminder to run in local not simulator.

Thanks again!

mtaulty wrote re: Windows 8 Metro Style App – Simple WNS Push Notification
on Sun, Jul 22 2012 12:22 AM

Hi Peter,

What worked is that my WPF application managed to authenticate to WNS and got a success code back from submitting the push notification.

My WPF application generated the message box.

Your metro app doesn't subscribe to that message - you should see your app's tile (or badge or toast) update based on the message that you sent from my WPF app.

Yes, I'd avoid the simular for push notifications - we've seen that before.

Peter Kellner wrote re: Windows 8 Metro Style App – Simple WNS Push Notification
on Sun, Jul 22 2012 11:07 PM

Hey thanks.  I did finally get things working thanks to your code as an example.  I'm still a little confused on on the URI generated.  Is that somehow unique to every device?  I assume it must be somehow.  What distinguishes one device form another?  that is, what in the couple lines of JavaScript you posted for getting that URL uniquely identifieds your metro devices?

Anonymous wrote re: Windows 8 Metro Style App – Simple WNS Push Notification
on Fri, Jul 27 2012 9:38 AM

what's the Notification Url