Sending a Toast Notification

Toast notifications require an XML envelope for the notification information. Listing 15.1 demonstrates how the creation of an XML envelope is constructed and sent to the MPNS. An HttpWebRequest is created using the push notification subscription URL. The notification XML is converted to a byte array, and then it is written to the outgoing request Stream. After sending the request, the response is examined to ensure that it was correctly received by the MPNS.

Note

For more information on the X-NotificationClass request header, and setting a notification’s priority level, see the upcoming section “Notification Classes.”

LISTING 15.1. PushNotifier Class (excerpt)

public PushNotificationSendResult ...

Get Windows® Phone 8 Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.