I don’t think I need to elaborate on how important it is to get ratings for your app in the Store – and preferably good ratings. By no means this is new and original: Matthijs Hoekstra wrote something to this effect, our Dutch DPE Rajen Kishna even made a NuGet package for similar stuff, Telerik have something in their magnificent Radcontrols for Windows Phone and yet me, being stubborn, need to make something of my own. The reason for this is simple: I wanted (of course) to make a behavior so you can add it to your app without any code at all – just drag it on top of your first opening page and it will work out of the box. And Blend will present you with some properties that you can set – or not. It works fine out of the box. As it does in my latest Windows Phone app, 2 Phone Pong.
If you drop the behavior on top of your start page it will work without modification. But Blend exposes four properties to customize it’s mode of operation:
- Caption is the text on top of the message box that will display when the app reminds the user. Default is “Review App”. You can set a different value in XAML or (better) bind it to a view model property holding a globalized text.
- MaxReminders is the number of times the behavior will ask the user to review. If the user refuses to review more than MaxReminders time, he will no longer be bothered.
- Message shows the actual reminder message. Default values is “You have used this app a few times now, would you like to review it in the store?”
- RemindFrequency is the number of app startups after which the review request is displayed.
So, with the default setting, the app will ask you the 7th, 14th and 21st time if you want to review the app. After the third dismiss, it won’t ask you anymore. This is to prevent users getting annoyed by endless review requests and giving negative reviews because of that. And of course it will stop asking the user when has elected to post a review.
The behavior itself is built on top of my wp7nl library on codeplex (of course) and implemented as a SafeBehavior. First, I created a simple data class to hold the data in local storage:
namespace Wp7nl.Behaviors { /// <summary> /// Simple data class to store data in used by RemindReviewBehavior /// </summary> public class RemindData { public int Starts { get; set; } public bool Reviewed { get; set; } public bool Refused { get; set; } } }
The behavior itself is also pretty simple – it sports four Dependency Properties with the same names as Blend shows – not coincidentally – in front of the text boxes in the image on top of this post.
The behavior itself starts simple enough, being a standard SafeBehavior:
namespace Wp7nl.Behaviors { /// <summary> /// A behavior to remind the user to review the app after a couple /// times using it /// </summary> public class RemindReviewBehavior: SafeBehavior<Page> { protected override void OnSetup() { CheckRemind(); } }
All the functionality is in the CheckRemind method:
private void CheckRemind() { var helper = new IsolatedStorageHelper<RemindData>(); var remindData =
helper.ExistsInStorage() ? helper.RetrieveFromStorage() : new RemindData(); if (!remindData.Reviewed && !remindData.Refused) { remindData.Starts++; if (remindData.Starts % RemindFrequency == 0) { var result = MessageBox.Show(Message, Caption, MessageBoxButton.OKCancel); if (result == MessageBoxResult.OK) { Review(); remindData.Reviewed = true; } else { if (remindData.Starts >= MaxReminders * RemindFrequency) { remindData.Refused = true; } } } helper.SaveToStorage(remindData); } }
Using the IsolatedStorageHelper from wp7nl it checks if there is already data from a previous run in local storage – if there is not, it is created. If Reviewed or Refused are true, no action in necessary. After, the number or starts is increased, and it checks if the number of starts can be divided by the RemindFrequency. If that is the case, the message is displayed,
If the user then decides to review the app, the Review method called and the Reviewed property is set to true so the user won’t be bothered anymore. If the user does not want to review, the app checks if the max number of review request has already been put out – and if so, the Refused property is set to true. The user is (also) no longer bothered anymore. And at the end, the remindData is saved so whatever happened in the method is saved for posterity.
The Review method then is pretty simple:
private void Review() { var marketplaceReviewTask = new MarketplaceReviewTask(); try { marketplaceReviewTask.Show(); } catch (InvalidOperationException ex) { } }
The only drawback is that the user can click OK, go to the Store, and then hit cancel. There is no way around cheaters, but if someone does not want to review, whatever – at least he/she then won’t give a bad review either.
The four dependency properties I leave out for the sake of brevity.
I have put the code into upcoming version of the wp7nl library, but for now you can get it from the demo solution. I have changed MaxReminders to 20 and RemindFrequency to 2 so the demo app will ask you every other time to rate it, for 20 times. This is a setting I would definitely not recommend in the wild, but it shows the point.
Now Matthijs, Rajen, me and several others have showed you multiple ways to get this done. Mine does not even require you to code – just drag and drop. Now make sure you implement any of these solutions. Whether you are in the Windows Phone game for fun, glory, money or all of the above – you want those apps downloaded. And ratings are crucial for that.
2 comments:
thanks, great :)
ok, I have one Question, It gives me the message when I enter the app every 2nd time, How can do that for Every 15 times ?
@Asif try setting RemindFrequency to 15.
Post a Comment