1 Comments

Microsoft has release a WP7 recipe called the “Windows Phone Server Side Push Notification Helper”. The recipe consist of a demo application which shows how one can send toast, tile and raw notifications. I’m working on an app which requires toast notifications so I decided to try the server side implementation of the app because it really makes the task of pushing notifications from your server to the phone easy. Here’s the only code you need (after compiling and adding the WindowsPhone.Recipes.Push.Messasges into your project):

var message = new ToastPushNotificationMessage (MessageSendPriority.High) {Title = title, SubTitle = subTitle};
message.SendAsync(uri, OnMessageSent );

Nice and simple. But still I manager to spend almost five hours to get this working. My app was receiving the notifications but only on random basis. Sometimes I got the message, sometimes I didn’t. The only way I managed to receive the message with a 100% success rate was by starting the app, sending the message from the server and then closing the app. After the app closed, I got the notification. But what happened when I tried to send an another message after that? Nothing. The server reported that the device had received the message but it didn’t.

I was completely sure that my client was causing the problem. I think I rewrote the whole code about three times and at one point I was sure that my problem had something to do with the Caliburn.Micro. But no. Creating a new Panorama App from a scratch didn’t help at all and it was acting just like the other app.

And then, finally, I gave up and started looking at the server code. I compared the differences between the recipe’s demo application (which was working nicely all the time) with my implementation and then it hit me: The demo app was passing the MessageSendPriority.High in to the message’s constructor, I wasn’t. And what do you know, after making the change into my server the notifications started working as they should! No more randomness, the notifications are hitting my phone with a 100% success rate.

So what is the MessageSendPriority? It seems to be a wrapper around the "X-NotificationClass” –header. The MSDN says this about the possible values:

// Possible batching interval values:
// 2: The message is delivered ... immediately.
// 12: The message is delivered ... within 450 seconds.
// 22: The message is delivered ... within 900 seconds.

This is how the recipe is calculating the value:

int batchingInterval = ((int)SendPriority * 10) + NotificationClassId;

In my case the NotificanClassId was 2 (meaning ToastPushNotificationMessage). By default the SendPriority was Normal, which represents the integer value 1. So, without setting the MessageSendPriority, the messages are delivered with the batching interval value 12, meaning that the message should be delivered in 450 seconds. 

I’m quite sure that this isn’t working correctly because I’m still missing like 100 messages. And this isn’t only an emulator problem because my actual device is missing the notifications also. So the bottom line is, use the MessageSendPriority.High, or if you’re sending the notifications manually, use the following values in the X-NotificationClass -header:

  • Tile notification: 1
  • Toast notification: 2
  • Raw notification: 3

0 Comments

WP7 SDK contains an easy-to-use ProgressBar-control. Unfortunately it has some design problems, most glaringly the fact it is UI thread bound. So if your UI is busy working on something, your ProgressBar will stop animating.

Instead of using the default ProgressBar, you should always use the so-called “PerformanceProgressBar”, a class and style combination created by Jeff Wilcox. Getting things started with the PerformanceProgressBar is easy, just follow the good instructions provided by Jeff.

0 Comments

Most of the WP7 applications use either the Panorama or the Pivot controls. It seems that you can solve most of the UI requirements by just using these two controls. But, some care should be taken. The pivot control at a first glance may look like a perfect solution for apps where the content must be split across hundreds of small views (think book, where each page is presented by a pivot item).

But beware: the PivotControl is a memory hog. An app with 150 empty PivotItems uses over 55MBs of memory. After adding the pivot items, there’s not much of memory left to add the actual content, when the memory limit of 90MB is kept in mind.

PanoramaControl fares much better in a similar test: An app with 150 empty PanoramaItems use only 21MBs of memory.

0 Comments

Here’s the first NServiceBus Weekly of the 2011, containing links to interesting tutorials and community material from the last couple of months. Hope you enjoy.

Also note: More random release frequency for the new editions.

News

  • NServiceBus 2.5 is now available.- Also, read the original announcement.
  • NServiceBus and BizSpark – Excellent news from the Udi for those who are in the Microsoft’s BizSpark program. In his own words: “if you're company is in BizSpark, in addition to all the software
    you're getting for free from Microsoft, I'm happy to offer you a free
    NServiceBus Foundation license or $1500 off a Standard license. That includes support.”

Tutorials and Articles

Community

Have a nice new year!

Got an interesting NServiceBus related link? Did I miss something? Link not working? Please, send mail or contact @MikaelKoskinen.

0 Comments

Unfortunately, as most of you have probably noticed, I have failed miserably to to keep-up with the weekly release rate of NServiceBus Weekly. Because of this, I’m giving up the planned weekly release schedule but still still plan to publish new editions quite frequently. It’s my hope that I also find time to write couple NServiceBus tutorials in the near future.

And here’s one big NServiceBus related news item: NServiceBus 2.5 has been released (some time ago) and it has a homepage with a new design.