Fix: Push Notifications in WP7
Posted on August 6, 2010 by Chris Koenig
After embarassing myself earlier this week with a demo I wrote a while back not working in front of a crowd, I tried to figure out what had happened to the Push Notifications stuff in WP7. Turns out, the service has changed post-Beta, and the existing code (including the code in the awesome Training Kit) no longer works.
The fix is here:
Basically what you have to do is comment out the lines that set the X-WindowsPhoneTarget HTTP header – one in prepareTilePayload:
//byte[] prefix = Encoding.UTF8.GetBytes("Content-Type: text/xml\r\nX-WindowsPhone-Target: tile\r\n\r\n");
//stream.Write(prefix, 0, prefix.Length);
and one in prepareToastPayload:
//byte[] prefix = Encoding.UTF8.GetBytes("Content-Type: text/xml\r\nX-WindowsPhone-Target: toast\r\n\r\n");
//stream.Write(prefix, 0, prefix.Length);
Comment out the 2 lines in each of those methods and you’re good to go!
Comments (4)

Fix: Push Notifications in WP7 « Development « Chris Koenig…
After embarassing myself earlier this week with a demo I wrote a while back not working in front of a crowd, I tried to figure out what had happened to the Push……
Wow! what an thought ! What a concept ! Stunning .
[...] Fix for Push Notifications in Windows Phone 7 [...]
[...] Fix for Push Notifications in Windows Phone 7 [...]