Click here to Skip to main content
13,343,328 members (54,150 online)
Click here to Skip to main content
Add your own
alternative version


12 bookmarked
Posted 31 Jul 2012

Windows Notification service in Metro style applications

, 31 Jul 2012
Rate this:
Please Sign up or sign in to vote.
Working with the Windows notification service in metro style application


The Windows Push Notification Service is used to enable a developer to send toast, tile and badge. WNS provides a mechanism to deliver new updates to the user.

Before we learn Windows Push Notification I would like to describe the Package.appmanifest file and its settings. This file is automatically created when you create a new Metro style project. This is an XML file that can contain the project configuration settings. Let's have a quick look at all these settings which are in the Package.appmanifest file.

This file allows us to set four kinds of settings (Application UI, Capabilities, Declarations, Packaging) as you can see in the below image. Application UI and Packaging settings are important in order to do Windows Push Notification.

[Remember]: In the above image all settings are OK but Toast capable settings are (not set), it means our application cannot send Toast. In order to allow our application to send Toast, we need to set yes in place of (Not Set). The image below shows the packaging settings.

Packaging settings allow us to set our live SDK setting, look at the Package name, it is a place where we need to add our package name and we can get this package name after we register our application on Windows Live Dashboard. Please click Register application on live dashboard to know how to register application on Live dashboard.

Now we move back on the Push notification. Let us see how the WNS server works in order to send Toast, Tile and badge.

The above image showing 6 steps, let we see all these steps one by one.

  1. Metro style application uses WinRT APIs to open a new Channel URI to server, so our application sent a request to Notification Client Platform.

  2. Notification Client makes a request to WNS server and get channel URI as response.
  3. Notification Client give this Channel URI to our metro style application

    Any 3rd party application need to obtain its client ID (SID) and client secret in order to communicate with cloud service. In order to get application client ID (SID) and client secret we need to register our application on live Dashboard (This article is push notification vie using live SDK). Please click Register application on live Dashboard to know how to register application on live dashboard.

  4. Metro style application send request to the Cloud server to get Authentication token.

    [Remember] we need to use Channel URI, Client Secret and Client ID (SID) in order to get access token from cloud service.

OAuthToken class is just have 2 property (Access Token and Token Type), It has sated by OnAuthenticate() method.

  1. Cloud Service creates a request to the WNS Server by using Channel URI and Authentication Token. If everything is going very smooth then WNS return status 200 as its response

[Remember]:PushWNS() method using Notification type and Notification XML. Please look at the below table to get idea of Notification Type and Notification XML.

Notification Name

Notification Type

Notification XML



"<?xml version='1.0' encoding='utf-8'?><badge value=\"2\"/>"



"<tile><visual version=\"1\"><binding template=\"TileWideText03\"> <text id=\"1\">Hello World! My tile notification</text></binding><binding template=\"TileSquareText04\"><text id=\"1\">Hello World!</text></binding></visual></tile>"



"<?xml version='1.0' encoding='utf-8'?><toast><visual version='1'><binding template='ToastText01'><text id='1'>My first Toast</text></binding></visual></toast>"

  1. Notification Client can get this response and send it to our application.

When I was starting learning this I was confused how to verify these Badge, Tile and toast are pushed or not, so let me tell you how to verify it

  1. Badge: Once you send badge successfully, please go to win8 Dashboard and check your application. Look at the below image

  2. Tile: Once you send Tile successfully, please go to win8 Dashboard and check your application. Look at the below image


  3. Toast: Once you send Toast successfully, just wait 2-3 second you will get a popup message. Look at the below image

I hope This article will help you to send push notification by using metro style application.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

No Biography provided

You may also be interested in...


Comments and Discussions

GeneralMy vote of 5 Pin
delibey26-Nov-12 15:00
memberdelibey26-Nov-12 15:00 
GeneralMy vote of 5 Pin
Christian Amado1-Aug-12 6:56
memberChristian Amado1-Aug-12 6:56 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.180111.1 | Last Updated 31 Jul 2012
Article Copyright 2012 by Naren Chejara
Everything else Copyright © CodeProject, 1999-2018
Layout: fixed | fluid