The end user experience is the first and foremost important characteristic of Windows Phone 7. An extra emphasis during the design of the phone was placed on making sure that applications do not drain the battery. Therefore, WP doesn’t allow your application
to run code in a background process, which means your application can’t poll some web service for information. Push Notification compensate for that restriction and allows you to send messages to a Windows Phone device even if your application is not currently
running. This lab covers Push Notifications mechanism and introduces the usage of HTTP services in Silverlight. During this lab, you will create the server-side logic needed to send messages through Push Notifications Services, as well as bind to and handle
push notification sent to the Windows Phone device.
Follow the Discussion
At first I thought it was going to be another great lab that failed to work on my machine. After unistalling and reinstalling the April Refresh of the Windows Phone Developer Tools CTP, opening both projects still raises an error (the dialog stating - Object reference not set to an instance of an object).
After dismising the dialog, both the WPF "Push Notification Client" and the Phone Emulator's "PushNotifications" do run; however, in my case the phone app isn't visible in the foreground. By selecting the "back arrow" on the phone, you can see the list of applications and select "PushNotifications" from there. Once, selected the status shows "Registration succeeded" and you can proceed to send Http notifications from the WPF client as per the instructions.
This functionality is so important for the success of the platform. It's like making everyone's application into a mini-exchange server.
Great work, great lab, great video.
I was close to become mad trying to make the push notificatons service works, when I have finally discover why I was always getting a "NotificationChannelOpenException".
Even if you follow every steps of the lab, you will get this exception. If you open the project from the lab sources, you will not get this exception.
So why do we have this exception ?
I hope this will help other folks!
Spot on Vivien.
Add a value for Publisher or your app when get a constant exception trying to open the channel.
What's up with the feedback loop here?
These labs are great but there are simple (often obvious) problems, and there are even people pointing them out and offering fixes, but nothing appears to come of it...
@Vivian Thank you for the update.
@BrianHilltop - we are pushing a new update today that fixes all these error in the documentation.
Thanks,
Yochay
I am getting PayloadFormatError for tile and toast if I follow the example as it is. wonder whether format of those two have changed? is there anyway to know what part of format is wrong? if Title and Toast requires specific format that MS decided beforehand, why not just provide methods that returns payload with correct format instead of making each users to construct same format string?
thank you
- heejae
Please fix the code for tile and toast notifications, i'm getting a PayloadFormatError and a WebException - 404 NotFound. Thank you.
Hello,
I have the same problem.
Regards.
I am getting webException 404 not found when i try to send the message.
using
(WeResponse
response = request.EndGetResponse(iarr))
{
//Notify the caller with the MPNS results
OnNotified(notificationType, (
HttpWebResponse
)response, callback);
}
Please help on this.
I thought there is something wrong in my lab, but I ran the End solution of Exercise2 and never be able to get to the httpChannel_ShellToastNotificationReceived. Breakpoint never hit nor Status gets updated with "Toast/Tile message: " + msg.
Bug report: try sending a toast notification while the app is running. It will crash immediately with an XmlException, saying "Data at the root level is invalid". (Toast is received normally if the app is *not* running.) This bug also exists in the sample solution, so it's not just a typo in my code. Does anyone know how to fix it?
I have other issue which is also reported in the link below
http://social.msdn.microsoft.com/Forums/en-US/windowsphone7series/thread/8ec2d7b2-5153-4b54-ba52-0aa0980d096e/#c6af0970-34f4-456d-bb79-9ff70c04ce68
Please anyone have a look at this?
To Matt:
Here is an example of how you can fix your issues. You need to first move the Notification Handling functionality into its own class and instantiate it in App.xaml.cs.
Also, in your App.xaml.cs, add code to unsubscribe from Toast Notification in Application_Launching and Application_Activated.
Example:
if (httpChannel.IsShellToastBound) httpChannel.UnbindToShellToast();
Then, add code to subscribe to toast notfication in Application_Deactivated and Application_Closing.
Example:
if (httpChannel.IsShellToastBound) httpChannel.BindToShellToast();
This will take care of the XmlException issue
Paul Wu
Unbinding the toast will avoid the problem but it also means you won't get any toast notification inside your program.
To actually fix the problem, you need to correct the XML that gets sent. This post has the right XML:
http://www.thisisfanzoo.com/Blog/JeffF/archive/2010/08/02/a-really-long-post-about-the-windows-phone-7-push.aspx
I replaced the prepareXXXPayload methods in the sample with the XML strings in that post and everything worked for me.
@BenM: Was wondering what was causing that. Thanks for the Tip!
got problems with the example:
httpChannel = new HttpNotificationChannel(channelName, "HOLWeatherService");
>>Procedes but i get ""httpChannel.ChannelUri Could not evaluate expression"" when i check my locals<<
Trace("Trying to open the channel");httpChannel.Open();
Dispatcher.BeginInvoke(() => UpdateStatus("Channel open requested"));
>>Nothing chrashes but i get stuck with "Channel open request".<<
Seems like there's a lot of people having similar problems. Plz help.
PS: I dont know why it doest crash after problems with creating the httpChannel. Also in the example, there was talk of handling the emulator error (the 30s thing) by waiting, but i am unable to find the coresponding code.
@Kosmatifizik: Iguess it doesnt like the "/n"s
Remove this comment
Remove this thread
close