Tag Archives: WinRT

Ask for User Rating: The Story of How I Doubled My Daily App Downloads

I currently have two apps in the Windows Store: Puzzle Frenzy and Puzzle Frenzy Kids. I’ve been closely monitoring user rating, feedback and request from day one and tried at the same time to tweak and improve the apps.

However, one thing I noticed quite fast was that my app was not getting too many ratings. Even if rating an app is possible in Windows 8 for all apps without extra work (bring up right side bar -> Settings -> Rate and review), my users were simply not doing that. On top of that, I noticed that my competitors’ apps and all the top apps in the same category had hundreds, thousands, even tens of thousands of ratings.

I also realized that the more ratings an app has, the higher it is placed in the Windows Store. It goes without saying that user ratings have a significant contribution to the ranking of the app.

Therefore, I decided to ask for user rating inside the apps, to see if the users will respond and rate my apps more frequently.

However, I found what I think is the sweet spot for getting users to rate the app:

  • I will ask users to rate the app only after they have engaged in (and hopefully enjoyed) the app, that is after they already played 3 puzzle games. By doing so, the users will most likely give it a good rating because they appear to have enjoyed the app enough to stay in the app and play all the 3 games.
  • I offer the user the choice not to rate it and ask again later. I tried not to be too annoying with these requests so I only display it after 3, 7, 15 or 30 games. If even after the fifth prompt the user hasn’t rated the app, I won’t bother him again because he most likely isn’t going to rate the app anyway.
  • I don’t bother the user again once he rated the app, but I still display a “Rate app” button on the home page, in case he changes his mind or wants to update his rating.
Puzzle Frenzy User Rating Prompt

Puzzle Frenzy User Rating Prompt

After introducing these changes, the number of ratings I was getting increased quite a lot.  In around one week I started to get the same number of ratings which before I was getting in one month.

As a consequence, (there were other factors for sure, but the user rating prompt was most likely the most important) the apps got ranked higher and higher, and they started getting more downloads.

On average, now I get around twice as many downloads as I did before.

I highly recommend adding such prompt to anyone developing apps on any platform.

Be ready however, with more ratings and feedback comes more responsibility.

Take user feedback into account and react to it as it will help you improve your app.

Good luck!

Ensuring Data Integrity Using Digital Signatures in WinRT

The data stored in Windows Storage  for Win8 Apps (equivalent of IsolatedStorage for WP8) can be accessed by users directly, even by using Windows Explorer.

The files are stored under C:\Users\<User>\AppData\Local\Packages\<AppName>\LocalState and even if <AppName> is actually a combination of publisher name, app name and another sequence of letters, it is pretty easy to tell which app is which.

If you are going to store data and you want to keep your users from modifying it, you have to make sure you have the right mechanisms in place for doing so.

Luckily, WinRT has some useful libraries for helping you accomplish file signing in Windows.Security.Cryptography namespace.

The classes in this namespace can help you ensure the integrity of a file by creating a digital signature whenever you save it, and by verifying the signature whenever you read the file.

Wikipedia is a good starting point for finding out more about Digital Signatures and RSA.

Here is how you initialize the all the variables needed for signing and signature verification:

var hashAlgorithmName = HashAlgorithmNames.Sha1;
var asymmetricKeyAlgorithmName = AsymmetricAlgorithmNames.RsaPkcs1;

hashAlgorithm = HashAlgorithmProvider.OpenAlgorithm(hashAlgorithmName);
asymmetricKeyAlgorithm = AsymmetricKeyAlgorithmProvider.OpenAlgorithm(asymmetricKeyAlgorithmName);

var privateKeyBuffer = Convert.FromBase64String(privateKeyString).AsBuffer();
privateKey = asymmetricKeyAlgorithm.ImportKeyPair(privateKeyBuffer, CryptographicPrivateKeyBlobType.Pkcs1RsaPrivateKey);

Here is how you create a signature:

public IBuffer Sign(IBuffer byteArrayBuffer)
{
var hashBuffer = hashAlgorithm.HashData(byteArrayBuffer);
var encryptedBuffer = CryptographicEngine.Encrypt(privateKey, hashBuffer, null);

var hashString = CryptographicBuffer.EncodeToBase64String(hashBuffer);
Debug.WriteLine("This is the hash:" + hashString);

var encryptedHashString = CryptographicBuffer.EncodeToBase64String(encryptedBuffer);
Debug.WriteLine("This is the encrypted hash:" + encryptedHashString);

return encryptedBuffer;
}

Here is how you verify a signature:

public bool VerifySign(IBuffer originalBuffer, IBuffer encodedHashBuffer)
{
var originalHashBuffer = hashAlgorithm.HashData(originalBuffer);
var decriptedHashBuffer = CryptographicEngine.Decrypt(privateKey, encodedHashBuffer, null);

byte[] originalHashArray;
byte[] decriptedHashArray;

CryptographicBuffer.CopyToByteArray(originalHashBuffer, out originalHashArray);
var originalHashString = Convert.ToBase64String(originalHashArray);
Debug.WriteLine("Original hash:" + originalHashString);

CryptographicBuffer.CopyToByteArray(decriptedHashBuffer, out decriptedHashArray);
var decryptedHashString = Convert.ToBase64String(decriptedHashArray);
Debug.WriteLine("Decrypted hash:" + decryptedHashString);

return originalHashString == decryptedHashString;
}

Notes:

  • In order to make it work, you need a private key which you can generate using:
var key = asym.CreateKeyPair(512);
  • For the sake of simplicity, I keep the private file as a resource inside the app, which is not necessarily a good idea. The only reason I do it in this way is because I want to prevent anyone from easily changing the content of the saved files. However, this approach can easily be improved by storing the private key into a secure location and retrieving it over a secure channel.

Remember! Signing a file won’t keep your users from seeing its content, it will only prevent them from modifying it, or let you know if they they did.

Good luck!

Puzzle Frenzy Update 1 is now live in Windows Store!

I’m pleased to announce that Puzzle Frenzy Update 1 has passed certification and is now live and ready for download in Windows Store.

The new update brings a lot of visual and performance improvements like:

  • Game ended popup that displays the rating for the current game
  • Pause game button and Game paused popup windows that shows a preview of the puzzle being solved
  • Pieces animation during sorting and shuffling as well as when the user finishes the game
  • Memory consumption improvements
  • Home page images loading time improvements
  • Piece animation when moving to the next puzzle
  • Image size decreased for screen resolutions matching the image format to leave room for unsolved pieces
  • The ability to go to App’s blog, Facebook page and Rate and review page from withing the app by bringing up the bottom app bar on the home page
  • Several minor bugfixes

As a consequence the app feels and is faster, more responsive, consumes less memory and delights the users with more animations.

Check it out in the Windows Store!

http://apps.microsoft.com/windows/en-GB/app/puzzle-frenzy/28238e98-ac0f-4a6b-81ea-a31a24a15acf

Puzzle Frenzy home page

Puzzle Frenzy home page

Building Jigsaw Puzzle Frenzy: sharing code between WP and WinRT

When I first started working on Puzzle Frenzy I wanted to maintain both the original WP app and also to create a new WinRT app by reusing and sharing as much code as possible.

My plan was based on the presentations at Build which promised  which promised up to 70% code share between  WP and WinRT. In particular check out Create Cross-platform Apps using Portable Class Libraries.

During different stages of the project I tried several approaches for achieving this goal:

Share physical source files between WP and WinRT projects

I initially started building the WinRT app adding new projects to the solution containing the same files as the WP.

The problem

While a low of classes in the WP and WinRT are “identical” in functionality, they are often not in the same  namespace.  On top of that, using the same source files in more then one project is by itself problematic.

Direct consequences:

1.Trying to use the same source files for both WP and WinRT resulted in files like this one:

#if WINDOWS_PHONE
using System.Windows.Media;
#else
using Windows.UI.Xaml.Media;
#endif

Furthermore, for some special cases I was forced to have constructions like this one:

#if WINDOWS_PHONE
//Do something
#else
//Do something else
#endif

2.Having the physical same file referenced by two projects in Visual Studio is a lot of work. Whenever something breaks for one project (90% of the time due to a usings declaration change) the file containing the error has to be opened from the context of the failing project. If the file is opened in the other project the error won’t be highlighted in the code and the solution won’t compile.

For few files, this setup can be maintained even if it is inconvenient. However, as the file count grows, keeping up with the changes is a too complicated task.

Using Portable Libraries

For the appropriate scenarios Portable Libraries are awesome. It eliminates the need for duplicated files altogether as the library can be referenced by both the WP and WinRT. In my case however I wasn’t able to use them because I use Point and Size classes throughout my project. These classes are not available in Portable Libraries. I could have created my own implementation of Point and Size to overcome this limitation, but given the scale of the changes I preferred not to do it: a simple search reveals that I use these classes in more than 100 places in my code.

From what I’ve experienced so far, Portable Libraries offer limited classes to work with. My ViewModels layer which I was planning to keep there needs far to many things which are not available.

Conclusion

Sharing code between WP8 and WinRT can prove to be troublesome.

Both duplicate projects and Portable Libraries have limitations, making it in my case are quite challenging to use.

If sharing the code between the two apps is really your goal, I am fairly confident it can be achieved. However, in my case, for this particular app, attempting to share the code only slowed me down. In the end I kept using duplicated projects but I am not maintaining them at the same time.

I take turns in development cycles implementing features and adjusting the code to work on the other platform. While doing so I introduce bugs in the project not being maintained at the time, but the amount of work needed to fix it is far less than implementing new features at once on both platforms.

Closing argument

If you start developing a new app and want to target WP and WinRT consider using Portable Libraries from the start. It will have some limitations but will also force you to place the code in the right place in order to be shared.

If you already have an WP app and want to migrate it to WinRT you might want to start by maintaining duplicated projects in order to limit the size of the changes needed. Once you reach a stable state you can of course look into  moving towards Portable Libraries if code sharing is your goal.

Have a look and see how it turned out.

Jigsaw Puzzle Frenzy is available in Windows Store, check it out and tell me what you think: http://apps.microsoft.com/windows/en-GB/app/puzzle-frenzy/28238e98-ac0f-4a6b-81ea-a31a24a15acf.

You can also give your feedback on app’s review page or on app’s Facebook page http://www.facebook.com/PuzzleFrenzyApp.

Happy codding!

Puzzle Frenzy home page

ListBox performance: WinRT vs. WP8 vs. WPF

With the raising popularity of WinRT and WP8 the demand for building complex UIs for managed apps increased significantly . A heavy UI which if not handled properly can lead to poor user experience.

This post will analyze the performance penalties of adding lots of visuals to a ListBox, present the traps of the “easy way” and suggest an alternative for overcoming them.

The problem

Take the following code which creates a collection of items and acts as a ItemsSource to an ListBox. The ListBox renders its items as Rectangles:

 
            
                
                    
                
            
        
        
            
        
        
		
        private void CreateRectangleItems()
        {
            var collection = new ObservableCollection();
            Random random = new Random();
            for (int i = 0; i < 1000; i++)
            {
                collection.Add(new Item()
                {
                    X = random.Next() % (int)this.ActualWidth,
                    Y = random.Next() % (int)this.ActualHeight
                });
            }

            this.DataContext = collection;
        }

       class Item
       {
              public int X { get; set; }
              public int Y { get; set; }
       }
While the code works just fine, it can consume up to 50 MB of memory, which is of course not ideal. Furthermore, the higher the number the items, the higher the memory consumption and the longer the time it takes to generate them e.g. 3000 items can consume more than 100 MB and take 2-3 seconds to be generated. Check out the graph below for a better picture of the behavior. I will call this approach the visuals approach.
Winrt Listbox memory consumption

The solution

Recently I found an efficient way of displaying large number of items while keeping the memory consumption low. Here’s how: replace all the visuals with a single Path visual built based a geometry where you can put as many elements as you want.
I will call this approach the geometry approach and here’s the code for a possible implementation:

            
        
        
            
        
        
			 
        private void CreateGeometryItems()
        {
            var collection = new ObservableCollection();
            var random = new Random();
            var item = new GeometryItem();
            var group = new GeometryGroup()
            {
                FillRule = FillRule.Nonzero
            };

            item.Shape = group;
            for (int i = 0; i < 9000; i++)
            {
                group.Children.Add(new RectangleGeometry()
                {
                    Rect = new Rect(random.Next() % (int)this.ActualWidth,
                           random.Next() % (int)this.ActualHeight, 10, 10)
                });
            }

            collection.Add(item);
            this.DataContext = collection;
        }
This change brings significant memory consumption improvements. Check out the improvements in the chart below (the geometry approach is marked with green)

listbox winrt memory  consumption

After seeing such massive improvements I got curios to see how this technique would work for other platforms like Windows Phone 8 and WPF.

For WP8, the results are pretty much similar, the geometry approach is couple of times faster and less memory expensive than the visuals approach.

listbox wp8 memory consumption

Surprisingly, on WPF the visuals approach is not as memory expensive as is on WinRT or WP. However, the geometry approach is still twice as fast and memory efficient.

listbox wpf memory consumption

Bottom line: if you want to display and manipulate 1000+ visual elements in a ListBox consider the geometry alternative presented above, especially when using WP8 or WinRT.

One more thing 🙂

I found this technique while I was working on my Win8 app Puzzle Frenzy.

The app is available in Windows Store, check it out and tell me what you think: http://apps.microsoft.com/windows/en-GB/app/puzzle-frenzy/28238e98-ac0f-4a6b-81ea-a31a24a15acf.

You can also give your feedback on app’s review page or on app’s Facebook page http://www.facebook.com/PuzzleFrenzyApp.

Happy coding!

Puzzle Frenzy home page

Puzzle Frenzy Windows 8 app has been released!!!

Hi everyone,

I am pleased to announce that the Puzzle Frenzy app has been release in Windows Store!

Puzzle Frenzy is a realistic jigsaw puzzle game which features over 70 hand-picked images, ideal for puzzle solving.

The game contains several difficulty levels ranging from 16 to 100 pieces.

During the game you can shuffle or sort the pieces and also get hints in case you get stuck.

You can download the app from here: http://apps.microsoft.com/windows/app/puzzle-frenzy/28238e98-ac0f-4a6b-81ea-a31a24a15acf

Puzzle Frenzy home page

Puzzle Frenzy home page

Puzzle Frenzy gameplay in fast forward:

If you have any comments or suggestions check out our  Facebook page or drop us an email at puzzlefrenzyapp@gmail.com.

The page contains details about the game, the story behind some of the images as well as news and updates.

You can also follow us on Twitter  or on Google+

I’m looking forward to your feedback and I hope you enjoy the game!

All the best!

Coming soon: Puzzle Frenzy Windows 8 App

Puzzle Frenzy app for Windows 8 is right around the corner!!!

Puzzle Frenzy home page

Puzzle Frenzy is an realistic jigsaw puzzle for board game lovers of all ages.

The app will feature tons of images and multiple levels of complexity which translate into endless hours of fun puzzle-solving action.

Check out and Like our Facebook page http://www.facebook.com/PuzzleFrenzyApp and I’ll keep you updated with news about the app when it launches.