Skip to content


Subversion checkout URL

You can clone with
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

136 lines (88 sloc) 7.403 kb

Add push notifications to your Mobile Services app

[AZURE.INCLUDE mobile-services-selector-get-started-push-legacy]

This topic shows you how to use Azure Mobile Services to send push notifications to a Windows Store 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.

[AZURE.NOTE]This topic shows you how to manually configure push notifications using Windows Notification Service (WNS) for a Windows Store app. You can use Visual Studio 2013 tools to automatically configure the same push notifications in a Windows app project. For more information, see the universal Windows app version of this tutorial.

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

  1. Register your app with WNS and configure Mobile Services
  2. Update the app to register for notifications
  3. Update server scripts to send push notifications
  4. Insert data to receive 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.

Register your app with WNS and configure Mobile Services

[AZURE.INCLUDE mobile-services-notification-hubs-register-windows-store-app]

Both your mobile service and your app are now configured to work with WNS and Notification Hubs. Next, you will update your Windows Store app to register for notifications.

Update the app to register for notifications

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

  1. Open the file default.js and insert the following code after the code that creates the MobileServiceClient instance:

    // Request a push notification channel.
        .then(function (channel) {
            // Register for notifications using the new channel

    This code retrieves the ChannelURI for the app from WNS, and then registers that ChannelURI for push notifications.

  2. Press the F5 key to run the app. A popup dialog with the registration key is displayed.

  3. Open the Package.appxmanifest file and make sure that in the Application UI tab, Toast capable is set to Yes.

    This makes sure that your app can raise toast notifications.

Update server scripts to send push notifications

[AZURE.INCLUDE mobile-services-javascript-update-script-notification-hubs]

Test push notifications in your app

[AZURE.INCLUDE mobile-services-windows-store-test-push]

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 the next tutorial, Send push notifications to authenticated users, which shows how to use tags to send push notifications from a Mobile Service to only an authenticated user.

Learn more about Mobile Services and Notification Hubs in the following topics:

Jump to Line
Something went wrong with that request. Please try again.