Development, WP7

Fix: Push Notifications in WP7

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!

4 thoughts on “Fix: Push Notifications in WP7

Comments are closed.