This sample shows how a client app can register and listen for push notifications that are sent from a web server. Push notifications can be used to update a badge or a tile, raise a toast notification, or launch a background task. Periodic notifications act in the other direction, polling a web server for tile or badge content at a fixed time interval.

Note  This sample was created using one of the universal app templates available in Visual Studio. It shows how its solution is structured so it can run on both Windows 8.1 and Windows Phone 8.1. For more info about how to build apps that target Windows and Windows Phone with Visual Studio, see Build apps that target Windows and Windows Phone 8.1 by using Visual Studio.

The sample demonstrates the following actions:

To obtain an evaluation copy of Windows 8.1, go to Windows 8.1.

To obtain an evaluation copy of Microsoft Visual Studio 2013, go to Visual Studio 2013.

Note  For Windows 8 app samples, download the Windows 8 app samples pack. The samples in the Windows 8 app samples pack will build and run only on Microsoft Visual Studio 2012.

Related topics

For JavaScript/HTML developers
Sending push notifications with WNS
How to authenticate with the Windows Push Notification Service (WNS)
How to request, create, and save a notification channel
How to set up periodic notifications for tiles
How to set up periodic notifications for badges
How to update a badge through push notifications
Quickstart: Sending a tile push notification
Quickstart: Sending a toast push notification
For C#/C++/XAML developers
Sending push notifications with WNS
How to authenticate with the Windows Push Notification Service (WNS)
How to request, create, and save a notification channel
How to set up periodic notifications for tiles
How to set up periodic notifications for badges
How to update a badge through push notifications
Quickstart: Sending a tile push notification
Quickstart: Sending a toast push notification
Related samples
Raw notifications sample
Windows 8 Windows Store app samples download pack

Operating system requirements

Client
Windows 8.1
Server
Windows Server 2012 R2
Phone
Windows Phone 8.1

Run the sample

The next steps depend on whether you just want to deploy the sample or you want to both deploy and run it.

Deploying the sample

Deploying and running the sample

How to use the sample

For any functionality that involves non-local content, the developer must have declared the "Internet (Client)" capability in the app's manifest. In the Visual Studio 2013 manifest editor, this option is under the Capabilities tab.

To run this sample, you need access to a web server that can store your notification channel, send push notifications to your client, and provide tile and badge update content when polled.

For tile and badge push notifications to work, your app tile must be able to receive notifications. Tile notifications can be disabled by a user for a single app or for all apps, or by a system administrator through group policy.

Windows Phone: External to this sample, you can experiment with push notifications in the Windows Phone emulator, through its Additional Tools flyout. This uses only local resources and does not require a web server, but it appears to the app that it is receiving a notification through Windows Push Notification Services (WNS).