Fix: Push Notifications in WP7

Posted on August 6, 2010 by

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:

http://social.msdn.microsoft.com/Forums/en-US/windowsphone7series/thread/64863ad2-895c-4179-8367-b846ad816fc5

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)

 

  1. 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……

  2. Wow! what an thought ! What a concept ! Stunning .

  3. [...] Fix for Push Notifications in Windows Phone 7 [...]

  4. [...] Fix for Push Notifications in Windows Phone 7 [...]