How to send push notifications to a running app with Visual Studio

Applies to Windows and Windows Phone

When you develop or test apps that use push notifications, you might want to send a notification to your app without having to modify your mobile service code. Visual Studio provides a convenient way to do this through Server Explorer.



Step 1: To send a push notification with Visual Studio

During the development and testing phase of an app, you might want to send push notifications to test your app's response to them. You might also want to trigger certain behavior in an app that's running on a remote device from a development machine. If the behavior is triggered by push notifications, you can compose and send a notification from Visual Studio that will trigger the desired behavior.

  1. In Server Explorer, expand the Notification Hubs node.
  2. Open the shortcut menu for the notification hub that you want to use to send your notification, and choose Send a notification.

  3. Choose whether to send to a specific tag or broadcast to all registered clients. If you want to send to a tag, choose the Tag option and specify the name of the tag. In this case, an app will receive the notification only if it has registered for the tag, using code like this:

    mymobileserviceclient1234Client.push.registerNative(channel.Uri, new Array("tag1", "tag2"))
  4. Choose the type of notification you want to send based on the target application type. The following notification types are available.

    Message typeFormatDescription
    Windows Store ToastWNS XMLText that pops up on the Windows Store client's screen.
    Windows Store TileWNS XMLAn update to a Windows Store tile.
    Windows Store BadgeWNS XMLAn icon or symbol that appears on a Windows Store tile.
    Windows Store RawBinaryArbitrary raw data.
    Windows Phone ToastMPNS XMLText that pops up on the phone's screen.
    Windows Phone TileMPNS XMLAn update to a Windows Phone tile.
    Windows Phone RawMPNS XMLArbitrary raw data.
    iOS DefaultJSONMessage compatible with iOS clients.
    Android DefaultJSONMessage compatible with Android clients.
    Custom Template DefaultJSONMessage that works with all types of clients.


    Tip  The types of notifications you send depend on the specific notification types that your client app supports. Some Windows Phone clients support the WNS notification type, but others use the Microsoft Push Notification Service (MPNS) type. If your client app uses the WNS client APIs (in the namespace Windows.Networking.PushNotifications), use the Windows Store templates. If your client uses the MPNS APIs (in the namespace Microsoft.Phone.Notification), use the Windows Phone templates.

    Depending on what you choose from the list, a template for that type of message appears in the Body text box. For an explanation of the different types of notification templates you can use for Windows Store apps, see The toast template catalog, The tile template catalog and the reference documentation for the XML schema.

    Edit the template to customize your notification.

    Tip  If you have multiple types of clients that accept messages in different formats, send different messages to each type of client. Each type of client only receives messages in the formats it supports.

  5. Edit the body to specify your message. When editing messages in the XML format, don't change the XML or JSON structure, just change the values inside the XML or JSON elements, such as the title and background image. Make sure that the result is correctly formatted XML or JSON.
  6. View the status of your notification in the Message Result area.

    View the status of the notification in the Message Result area.

    Tip  The test message is sent to no more than 10 random registered clients.

  7. If sending the notification fails, make sure that a client app is registered for push notifications from the notification hub you're using, and that the type of the message you chose is appropriate for at least one client app.

Related topics

Quickstart: Adding push notifications to a mobile service
Quickstart: Add a mobile service
Notification Hubs Tutorials and Guides
Notification Hubs Overview
Getting Started with Notification Hubs
Notify users with Notification Hubs
Using Notification Hubs to send breaking news



© 2014 Microsoft