I have seen a few blog posts that explain how to prompt a user to rate your app after a few visits. These posts describe how to store a setting for how many times the app has been opened and whether the prompt has been shown. Some use a custom message box and some use the built in MessageBox. There have even been NuGet packages for this. I have to wonder, Why are you not using Telerik’s RateApplicationReminder? After all, if you do not have Telerik’s controls, you might be doing something wrong.
Telerik’s RateApplicationReminder is a great tool to have. It allows users to ignore further reminders. It allows you to specify if the reminder should not be shown any more if the user taps the yes button. The text it displays is fully customizable, including the buttons. It also allows you to show the reminder based on number of times the app has opened or days from the last reminder. Oh, and it helps increase app reviews.
The RateApplicationReminder is used in conjunction with the ApplicationUsageHelper. The ApplicationUsageHelper tracks how many times a user has opened the app on a certain version. It’s a simple tool to use, insert one line of cod in the Launching and Activated event of your Application.
private void Application_Launching(object sender, LaunchingEventArgs e)
{
ApplicationUsageHelper.Init("1.0.0");
}
private void Application_Activated(object sender, ActivatedEventArgs e)
{
ApplicationUsageHelper.OnApplicationActivated();
}
It is required to use the ApplicationUsageHelper. With this in place we can take advantage of RateApplicationReminder to prompt users to rate your app. When you create the reminder, specify how it should be shown (or not shown) based on user interaction and the content of the prompt.
var reminder = new RadRateApplicationReminder
{
// Show the checkbox to the user to not show again
AllowUsersToSkipFurtherReminders = true,
// Do not show again if they press yes
SkipFurtherRemindersOnYesPressed = true
};
reminder.MessageBoxInfo.Content = "Would you like to rate this awesome app?";
Once you specify how to handle user interaction, set when the reminder will be shown. You can specify to show the reminder by setting the RecurrencePerUsageCount property, the RecurrencePerTimePeriod property, or a combination of both. You never need to check if you should show the reminder. All you need to do is call the Notify method. Telerik handles if the reminder should be shown.
If the reminder has never been shown these properties are based on the number of times the app has been opened or when the app was first opened. These values of how many times and when the application was opened come from the ApplicationUsgaeHelper.
If the reminder has been shown, the RecurrencePerUsageCount property specifies how many times the Notify method should be called before the reminder is actually shown. The RecurrencePerTimePeriod property specifies a TimeSpan from the last time the reminder was shown. You can set both properties. When this happens the reminder will first see if the RecurrencePerUsageCount has been met, if it has not, it will then check if the time since the reminder was last shown is greater than sRecurrencePerTimePeriod.
I like to use both properties, but not at the same time. It’s possible that a user may open the app 10 times in a day and I do not want to prompt them all the time. To take advantage of both settings, I check if the reminder has been shown before. You can do this by checking the LastReminderDisplayDate. This is a nullable DateTime and will be null if the reminder has never been shown.
if (reminder.LastReminderDisplayDate.HasValue == false)
{
// reminder has not been shown before, allow the APP to open five times
// before showing the reminder
reminder.RecurrencePerUsageCount = 5;
}
else
{
// reminder has been shown, show once every three days
reminder.RecurrencePerTimePeriod = TimeSpan.FromDays(3);
}
In the snippet above I specify that the first time the reminder should be shown is when the app has been opened five times. Afterwards, it will open every three days. The following prompts from the reminder are only if the user taped the no button and has not checked the option to ignore future reminders. Remember, all of this is handled for you. The last thing to do is “show” the reminder.
// only shows the reminder when/if it is suppose to!
reminder.Notify();
Remember, no code to check how many time the app has been opened. No code to save/check if future reminders are disabled. You code is very simple. When we put all the snippets together we get the following
var reminder = new RadRateApplicationReminder
{
// Show the checkbox to the user to not show again
AllowUsersToSkipFurtherReminders = true,
// Do not show again if they press yes
SkipFurtherRemindersOnYesPressed = true
};
reminder.MessageBoxInfo.Content = "Would you like to rate this awesome app?";
if (reminder.LastReminderDisplayDate.HasValue == false)
{
// reminder has not been shown before, allow the APP to open five times
// before showing the reminder
reminder.RecurrencePerUsageCount = 5;
}
else
{
// reminder has been shown, show once every three days
reminder.RecurrencePerTimePeriod = TimeSpan.FromDays(3);
}
// only shows the reminder when/if it is suppose to!
reminder.Notify();