App Rating Reminder for ‘Windows Store’ apps

My older post is about the app rating reminder for windows phone. For Windows 8, it is similar only with little difference, so to clear it out, here is the code. The concept is that we will display a reminder every 3 times the application is launched until the user rates the app.You can write the code below in the page_loaded event as below:

private async void Page_Loaded(object sender, RoutedEventArgs e)
{

var settings = Windows.Storage.ApplicationData.Current.LocalSettings;
if (!settings.Values.ContainsKey("WasLaunched"))
{
Windows.Storage.ApplicationData.Current.LocalSettings.Values["ratingDone"] = "False";
settings.Values.Add("WasLaunched", true);
Windows.Storage.ApplicationData.Current.LocalSettings.Values["Count"] = 1;
}
else
{
var c = Windows.Storage.ApplicationData.Current.LocalSettings.Values["Count"];
int count = Convert.ToInt32(c);
count++;
Windows.Storage.ApplicationData.Current.LocalSettings.Values["Count"] = count;

if (Windows.Storage.ApplicationData.Current.LocalSettings.Values["ratingDone"].ToString() == "False")
if (count % 3 == 0)
{
MessageDialog msgDialog = new MessageDialog("Please rate the application", "App rating");

//OK Button
UICommand okBtn = new UICommand("OK");
okBtn.Invoked = OkBtnClick;
msgDialog.Commands.Add(okBtn);

//Cancel Button
UICommand cancelBtn = new UICommand("Cancel");
cancelBtn.Invoked = CancelBtnClick;
msgDialog.Commands.Add(cancelBtn);

//Show message
msgDialog.ShowAsync();
}
}
}

 

Now the methods for Ok and Cancel button:

private void CancelBtnClick(IUICommand command)
{
// nothing shall happen if we cancel
}

private async void OkBtnClick(IUICommand command)
{
Windows.Storage.ApplicationData.Current.LocalSettings.Values["ratingDone"] = "true";
await Launcher.LaunchUriAsync(new Uri(String.Format("ms-windows-store:REVIEW?PFN={0}", Windows.ApplicationModel.Package.Current.Id.FamilyName)));

}

In the OkBtn event, we are storing the package name of our application, While testing, it will lead to the store rating page but display an error message that App is no longer available. It will be shown once the app is on store.