![]() |
VOOZH | about |
As Xamarin.Forms is no longer maintained by Microsoft since May 1, 2024, this package is now officially deprecated. Please see Plugin.Maui.AppRating that use the latest version with .Net Maui.
dotnet add package Plugin.XamarinAppRating --version 1.2.2
NuGet\Install-Package Plugin.XamarinAppRating -Version 1.2.2
<PackageReference Include="Plugin.XamarinAppRating" Version="1.2.2" />
<PackageVersion Include="Plugin.XamarinAppRating" Version="1.2.2" />Directory.Packages.props
<PackageReference Include="Plugin.XamarinAppRating" />Project file
paket add Plugin.XamarinAppRating --version 1.2.2
#r "nuget: Plugin.XamarinAppRating, 1.2.2"
#:package Plugin.XamarinAppRating@1.2.2
#addin nuget:?package=Plugin.XamarinAppRating&version=1.2.2Install as a Cake Addin
#tool nuget:?package=Plugin.XamarinAppRating&version=1.2.2Install as a Cake Tool
Plugin.XamarinAppRating gives developers a fast and easy way to ask users to rate the app in the stores.
Plugin.XamarinAppRating is available via NuGet, grab the latest package and install it in your solution:
Install-Package Plugin.XamarinAppRating
| Platform | Version |
|---|---|
| Xamarin.Android | API 25+ |
| Xamarin.iOS | iOS 9.0+ |
| Xamarin.tvOS | All |
| Xamarin.macOS | All |
| UWP | Build 18362+ |
Call CrossAppRating.Current from any project to gain access to the APIs.
There are two main methods, PerformInAppRateAsync and PerformRatingOnStoreAsync.
/// <summary>
/// Perform rating without leaving the app.
/// </summary>
public Task PerformInAppRateAsync();
This method will open an in-app review dialog, using the
packageNamedeclared on theAndroidManifestfile.
/// <summary>
/// Perform rating on the current OS store app or open the store page on browser.
/// </summary>
public Task PerformRatingOnStoreAsync()
This method will open Google Play app on the store page of your current application. Otherwise, it will try to open the store page on the browser.
If neither the store page nor the browser store page works, it will display an alert announcing the error.
packageName must be provided as a named argument to open the store page on the store app or browser.
if (CrossAppRating.IsSupported)
await CrossAppRating.Current.PerformRatingOnStoreAsync(packageName: "com.facebook.katana");
/// <summary>
/// Perform rating without leaving the app.
/// </summary>
public Task PerformInAppRateAsync();
For iOS: if the device's current OS version is 10.3 or newer, this method will raise an in-app review popup of your current application, otherwise, it will display an alert announcing that it's not supported.
/// <summary>
/// Perform rating on the current OS store app or open the store page on browser.
/// </summary>
public Task PerformRatingOnStoreAsync()
This method will open App Store app on the store page of your current application. Otherwise, it will try to open the store page on the browser.
If the method fails, it will display an alert announcing the error.
applicationId property is the StoreId of your app and it must be provided as a named argument to open the store page on the store app or browser.
if (CrossAppRating.IsSupported)
await CrossAppRating.Current.PerformRatingOnStoreAsync(applicationId: "id284882215");
/// <summary>
/// Perform rating without leaving the app.
/// </summary>
public Task PerformInAppRateAsync();
If the target version build is 17763 or above, this method will raise an in-app review dialog of your current application, otherwise, it will display an alert announcing that it's not supported.
/// <summary>
/// Perform rating on the current OS store app or open the store page on browser.
/// </summary>
public Task PerformRatingOnStoreAsync()
This method will open Microsoft Store application with the page of your current app.
If the method fails it will display an alert announcing the error.
productId is the ProductId of your UWP app and it must be provided as a named argument to open the store page app.
if (CrossAppRating.IsSupported)
await CrossAppRating.Current.PerformRatingOnStoreAsync(productId: "9wzdncrf0083");
⚠️ Warning - You should be careful about how and when you ask users to rate your app, there may be penalties from stores. As for advice, I recommend using a counter on the app start and storage that count, then when the counter reaches a certain number, display a dialog asking the users if they want to rate the app, if they decline the offer, reset the counter to ask them later, also leave the option to do it themselves.
public partial class MainPage : ContentPage
{
private const string androidPackageName = "com.facebook.katana";
private const string iOSApplicationId = "id284882215";
private const string uwpProductId = "9wzdncrf0083";
public MainPage()
{
InitializeComponent();
if (!Preferences.Get("application_rated", false))
Task.Run(() => CheckAppCountAndRate());
}
private async Task CheckAppCountAndRate()
{
if (Preferences.Get("application_counter", 0) >= 5)
{
if (!await DisplayAlert("Rate this App!", "Are you enjoying the app so far? Would you like to leave a review in the store?", "Yes", "No"))
{
Preferences.Set("application_counter", 0);
return;
}
await RateApplicationInApp();
}
}
private Task RateApplicationInApp()
{
if (CrossAppRating.IsSupported)
{
Device.BeginInvokeOnMainThread(async () =>
{
// This method will simulate Facebook™ app to in-app rating as example.
await CrossAppRating.Current.PerformInAppRateAsync();
});
Preferences.Set("application_rated", true);
}
return Task.CompletedTask;
}
private Task RateApplicationOnStore()
{
if (CrossAppRating.IsSupported)
{
Device.BeginInvokeOnMainThread(async () =>
{
// This method use Facebook™'s store apps as example.
await CrossAppRating.Current.PerformRatingOnStoreAsync(packageName: androidPackageName, applicationId: iOSApplicationId, productId: uwpProductId);
});
Preferences.Set("application_rated", true);
}
return Task.CompletedTask;
}
private void InAppRating_Clicked(object sender, EventArgs e)
{
if (!Preferences.Get("application_rated", false))
Task.Run(() => RateApplicationInApp());
}
private void AppRateOnStore_Clicked(object sender, EventArgs e)
{
if (!Preferences.Get("application_rated", false))
Task.Run(() => RateApplicationOnStore());
}
}
Take a look at the TestApp sample for Xamarin.Forms or TestAppNative sample for Xamarin native fully detailed implementation of this plugin.
Please, feel free to open an Issue if you found any bugs or submit a PR.
XamarinAppRating is licensed under MIT.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. monoandroid12.0 monoandroid12.0 is compatible. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Universal Windows Platform | uap10.0.18362 uap10.0.18362 is compatible. |
| Xamarin.iOS | xamarinios xamarinios was computed. xamarinios10 xamarinios10 is compatible. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. xamarinmac20 xamarinmac20 is compatible. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. xamarintvos10 xamarintvos10 is compatible. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
This package is not used by any NuGet packages.
This package is not used by any popular GitHub repositories.