Out of trouble! With the help of a local Windows Phone champ!

Alright, I started all the trouble myself, but wasn’t aware of it!

What I did?

I created a separate app for Windows Phone 8, similar to Windows Phone 7 but a complete new code base. At that time I also did not have interest in making the Windows Phone 8 app multilingual. The Windows Phone 8 app only supported Dutch, instead of the three languages that were supported by the Windows Phone 7 app. The expected result I thought: Windows Phone 8 will only get the Dutch app, the Windows Phone 7 users are going to get the multilingual app.

The actual result

Testing was successful, but the Windows Phone 8 specific version doesn’t appear in the Store. I didn’t know what to do, so I asked my local Windows Phone champ, Rajen Kishna. He contacted the Windows Phone team, and came back with the cause and even a solutions.

The cause

As you can see in below screenshot the supported languages are different for the two versions of the app. The Windows Phone team explained that when the language selection isn’t equal the oldest version is served.

Store details

The solution

Make sure that the language selection is equal for both apps. Probably most of us would make sure that the Windows Phone 8 app would support German and English as well. I didn’t, but the main reason for this is the business model behind the app (I’m only earning money with the Dutch version).

A small tale of bringing push notifications to Windows Azure

Some time ago I got more and more problems on my shared hosting because it couldn’t handle the amount of push notifications I wanted to send. I heard my hosting provider tell me that I was quite often taking more than 90% of the CPU on the server. So I thought to give Windows Azure a try.

I wanted to make optimal use of Windows Azure so I designed my solution to make use of Windows Azure Table Storage to store registered devices and pushchannels. When making use of Azure Table Storage it’s important to choose your RowKey and PartitionKey carefully.

To start with the PartitionKey, I chose to put the ApplicationName in there. I want to send push notifications to different applications I created, like Fokke & Sukke and iBood. So far I haven’t found a reason I made a wrong decision.

And now the RowKey, something that I need to use more carefully. The combination of PartitionKey and RowKey needs to be unique. So I wanted to put the DeviceId of the Device that should receive the PushNotification in there, that combined with the platform identifier. As far as I know there’s nothing that guarantees that the DeviceId is unqiue over different platforms. So I prefix the DeviceId with “WP|” for Windows Phone and “RT|” for Windows 8. The rest was just the copy of the DeviceId. I tested this using the emulator, and everything seems to work fine.

Windows Phone app trouble

After a while I notices reviews telling me that Push Notification don’t work, even further, it didn’t work on my own Windows Phone. After searching for many different reasons for this trouble, I found the source, more or less.

When saving an entity to the Azure Table Storage, every now and then a StorageException occurred. There aren’t many details in the exception, so after attaching Fiddler to my Nokia Lumia 920, I saw interesting stuff happening on the line.

The DeviceId contained special characters. I didn’t notice this when using the emulator, because the DeviceId on the emulator didn’t contain any special characters. So in total I had a percentage of users that could never register because of the StorageException, I still have no idea how large that percentage is, DeviceIds at least regularly contain the ‘/’ character.

Lesson learned, make sure the RowKey and PartitionKey don’t contain special characters: /, \, #, ?

Windows Style app trouble

Besides the Windows Phone issues, I had a very strange behavior on Windows 8 as well. It happened that I was sending a push notification to my local (installed through Visual Studio) app that did not appear. For example I sent a BadgeNotification with value 1 and sometimes the value 17 appeared. I have been trying to find the reason behind it, I never found it. Because when I tried to debug it explicitly with a value like 4 it did show 4. I never got feedback about issues with the push notifications on Windows 8 since my move to Windows Azure, but my dev-machine had troubles.

So after a couple of weeks trying to find causes for the problem I did something that was my final call. I did uninstall the app, and installed the app from the Store. What happened? The pushnotifications started behaving correctly. I have no understanding about the differences between the apps, but it’s good to be aware that there seem to be differences between the app installed from the store and the app installed by Visual Studio.

Your app, featured in the Store, WOW!

The first week of March, one of my Windows 8 apps got featured in the Dutch Windows 8 Store. There are a lot of things you can do to increase the amount of downloads your app is getting, but getting featured helps a lot. Normally the app get’s about 10 to 15 downloads a day, during the featured period it was around 110 each day (178 on March 3rd).

 

image

Of course the “how to get featured” is a big secret. We do know, not providing the promotional art during the submission process will not help your app getting featured.

If you have any tips, please share them in the comments.

Cancel a Thread.Sleep uh Task.Delay the right way

To wait, or not to waitIn one of my Windows Azure Workers I’m using a back-off algorithm to expand the time between checking the queue for new messages. In my solution the time between checks can become as large as 5 minutes. While that helps in making sure I’m not creating unnecessary data transactions and limit the cpu-usage, it won’t help me when I’m deploying a new update. When a new deployment is done the old-running deployment will be gracefully shutdown. Meaning it waits until all processes are done. In the case of a sleep of 5 minutes, it will wait until it’s ready with that sleep instead of cancelling that sleeping. I thought that to be strange, so I was looking into a nice solution.

The solution is easy as long as you have a CancellationToken available to pass to the Task.Delay method. You can create a CancellationToken by using the CancellationTokenSource. I’ve always been using the overload that just takes one argument, but the overload that takes two arguments allows cancellation. The below sample application explains how to use it.

internal class Program
{
    private static void Main(string[] args)
    {
        var tokenSource = new CancellationTokenSource();
        Task consoleReadTask = Task.Run(
            () =>
                {
                    Console.WriteLine("Press the enter key to cancel execution of tasks.");
                    Console.ReadLine();
                    tokenSource.Cancel();
                });

        Task workerTask = Task.Run(
            async () =>
                        {
                            CancellationToken token = tokenSource.Token;
                            try
                            {
                                while (!token.IsCancellationRequested)
                                {
                                    Console.WriteLine("Task output @ {0}", DateTime.Now);
                                    await Task.Delay(60000, token);
                                }
                            }
                            catch (OperationCanceledException)
                            {
                                Console.WriteLine("Cancelled @ {0}", DateTime.Now);
                            }
                        });

        Task.WaitAll(consoleReadTask, workerTask);
        Console.WriteLine("Press the enter key to exit.");
        Console.ReadLine();
    }
}

dotNed Podcast–Windows 8 and Windows Phone 8

A couple of weeks ago Maurice de Beijer recorded a podcast interview with me for the dotNed usergroup. It’s about Windows 8 and Windows Phone 8, but completely in Dutch. If you’re interested but haven’t listened to it yet, give it a try.

dotNed Podcast - Windows 8 en Windows Phone 8 met Mark Monster