This topic shows you how to use Azure Mobile Services to send push notifications to a Windows Phone Silverlight app. In this tutorial you enable push notifications using Azure Notification Hubs to the quickstart project. When complete, your mobile service will send a push notification using Notification Hubs each time a record is inserted. The notification hub that you create is free with your mobile service, can be managed independent of the mobile service, and can be used by other applications and services.

This tutorial walks you through these basic steps to enable push notifications:

This tutorial is based on the Mobile Services quickstart. Before you start this tutorial, you must first complete either Get started with Mobile Services or Get started with data to connect your project to the mobile service. When a mobile service has not been connected, the Add Push Notification wizard creates this connection for you.

NOTE:

To send push notifications to a Windows Phone 8.1 Store app, follow the Windows Store app version of this tutorial.

Update the app to register for notifications

Before your app can receive push notifications, you must register a notification channel.

In Visual Studio, open the file App.xaml.cs and add the following using statement:

Test push notifications in your app

In Visual Studio, press the F5 key to run the app.

NOTE:

You may encounter a 401 Unauthorized RegistrationAuthorizationException when testing on the Windows Phone emulator. This can occur during the RegisterNativeAsync() call because of the way the Windows Phone emulator syncs it's clock with the host PC. It can result in a security token that will be rejected. To resolve this simply manually set the clock in the emulator before testing.

In the app, enter the text "hello push" in the textbox, click Save, then immediately click the start button or back button to leave the app.

This sends an insert request to the mobile service to store the added item. Notice that the device receives a toast notification that says hello push.

NOTE:

You will not receive the notification when you are still in the app. To receive a toast notification while the app is active, you must handle the ShellToastNotificationReceived.aspx) event.

Next steps

This tutorial demonstrated the basics of enabling a Windows Store app to use Mobile Services and Notification Hubs to send push notifications. Next, consider completing one of the following tutorials: