Windows Phone 7 Notification Service Updates

There are some changes that you need to make if you want Windows Phone 7 notifications to work with the April refresh of the developer tools (from readme):

Update Publisher

You need to specify a publisher in the WMAppManifest.xml file. Default value is “”. Can be anything, so long as it’s not empty (or missing)

<?xml version="1.0" encoding="utf-8"?> 

  <App  ProductID="{b2a3afee-70be-40c7-8dc1-81ac8c14163e}" 
          Title="Notifications" RuntimeType="SilverLight" 
          Version=""  Genre="NormalApp"  
          Author="Nick Randolph" Description="Notification App"  

Toast Notification Format

Format of the message has changed from:

var messageTemplate = "Content-Type: text/xmlrn" +
"X-WindowsPhone-Target: toastrnrn" +
"<?xml version="1.0" encoding="utf-8" ?>" +
"<wp:PushNotification id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:f998bcd1-3b66-4943-b517-0d7340352589" class="wlWriterEditableSmartContent">

var messageTemplate = "Content-Type: text/xmlrn" +
"X-WindowsPhone-Target: toastrnrn" +
"<?xml version="1.0" encoding="utf-8"?>" +
"<wp:Notification id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:15f1c293-d2ec-4d7d-9441-c71f25eb77a0" class="wlWriterEditableSmartContent">

var messageTemplate = "Content-Type: text/xmlrn" +
"X-WindowsPhone-Target: tilernrn" +
"<?xml version="1.0" encoding="utf-8" ?>" +
"<wp:PushNotification id="scid:812469c5-0cb0-4c63-8c15-c81123a09de7:910c0ac2-500e-485e-abd3-3069c9e6985d" class="wlWriterEditableSmartContent">

var messageTemplate = "X-WindowsPhone-Target: tokenrnrn" +
"<?xml version="1.0" encoding="utf-8"?>" +
"<wp:Notification >this post which covers how to pin your application to the Start area.


A last comment:

If you are wondering why your notifications are not being received on the emulator you may also see the following exception in the debugger output window:

A first chance exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll

This usually happens if the notification message you are trying to send is corrupt or ill formed (I’m not sure of the exact cause). At the moment the only way I’ve found to recover from this exception is to reboot the emulator. If you attempt to restart the application you will simply continue to see this exception for every notification you try to send.

Leave a comment