Plugin.Maui.AppRating
1.2.2
dotnet add package Plugin.Maui.AppRating --version 1.2.2
NuGet\Install-Package Plugin.Maui.AppRating -Version 1.2.2
<PackageReference Include="Plugin.Maui.AppRating" Version="1.2.2" />
<PackageVersion Include="Plugin.Maui.AppRating" Version="1.2.2" />
<PackageReference Include="Plugin.Maui.AppRating" />
paket add Plugin.Maui.AppRating --version 1.2.2
#r "nuget: Plugin.Maui.AppRating, 1.2.2"
#:package Plugin.Maui.AppRating@1.2.2
#addin nuget:?package=Plugin.Maui.AppRating&version=1.2.2
#tool nuget:?package=Plugin.Maui.AppRating&version=1.2.2
Plugin.Maui.AppRating
Plugin.Maui.AppRating
gives developers a fast and easy way to ask users to rate the app on the stores.
Platforms supported
Platform | Version |
---|---|
.Net MAUI Android | API 21+ |
.Net MAUI iOS | iOS 14.2+ |
Windows | 10.0.17763+ |
Mac Catalyst | 15.0+ |
Installation
Plugin.Maui.AppRating
is available via NuGet, grab the latest package and install it in your solution:
Install-Package Plugin.Maui.AppRating
In your MauiProgram
class add the following using statement:
using Plugin.Maui.AppRating;
Finally, add the default instance of the plugin as a singleton to inject it in your code late:
builder.Services.AddSingleton<IAppRating>(AppRating.Default);
Version 1.2.2
New Features
- Updated
Xamarin.Google.Android.Play.Review.Ktx
package for Android. - Updated iOS/MacCatalyst by the new
AppStore.RequestReview
from iOS and MacCatalyst version 16 and above. - Added
ThrowErrors
property to allow users to catch exceptions with the new error handling implementation. - Implemented improvements for error handling.
- Removed old error alerts.
- Applied code improvements to the library.
- Update sample project.
Click here to see the full Changelog!
⚠️ Considerations regarding new platform policies ⚠️
Android
- It's highly recommended to test this or any other store review plugin on a real device with Google Play installed instead of using an emulator.
- Due to new regulations from Google, the review dialogue will not be displayed on manual distribution or debug mode (apparently), only on apps published and distributed via Google Play Store, however, it is recommended to release your app under "Internal distribution" or "Internal App Sharing" to effectively test the store review popup. Read here for more information. Additionally, you can debug the error using
adb logcat
. FakeReviewManager
is a new feature released by Google, primarily designed for testing and unit testing purposes. It operates without a user interface (UI). For more information, visit the official Android documentation.- To integrate
FakeReviewManager
in your implementation of this plugin, passtrue
to the methodPerformInAppRateAsync
. This feature is exclusive to Android.
iOS
- During development, submitting a review is not possible, but the review popup dialog will still show on your simulator or device.
- ⚠️ The review dialogue will not be opened if the app is downloaded from TestFlight.
API Usage
Call the injected interface in any page or viewmodel to gain access to the APIs.
There are two main methods in the plugin: PerformInAppRateAsync
and PerformRatingOnStoreAsync
.
Android
/// <summary>
/// Perform rating without leaving the app.
/// </summary>
Task PerformInAppRateAsync(bool isTestOrDebugMode = false);
This method will open an in-app review dialogue, using the
packageName
declared on theAndroidManifest
file.
/// <summary>
/// Perform rating on the current OS store app or open the store page on the browser.
/// </summary>
Task PerformRatingOnStoreAsync();
This method will open the Google Play app on the store page of your current application. Otherwise, it will try to open the store page on the browser.
/// <summary>
/// If set to true, exceptions will be thrown when an error occurs.
/// </summary>
bool ThrowErrors
This will allow users to catch exceptions with the new error handling implementation.
If neither the store page nor the browser store page works, it will display an error through the console and throw the exception if ThrowErrors
is set to true
.
packageName
must be provided as a named argument to open the store page on the store app or browser.
Example
await _appRating.PerformRatingOnStoreAsync(packageName: "com.instagram.android");
iOS | Mac Catalyst
/// <summary>
/// Perform rating without leaving the app.
/// </summary>
Task PerformInAppRateAsync();
if the device current OS version is 10.3+ in iOS, or 14.0+ in Mac Catalyst, this method will raise an in-app review popup of your current application, otherwise, it will display a console log error announcing that it's not supported.
/// <summary>
/// Perform rating on the current OS store app or open the store page on the browser.
/// </summary>
Task PerformRatingOnStoreAsync();
This method will open the App Store app on the store page of your current application. Otherwise, it will try to open the store page on the browser.
/// <summary>
/// If set to true, exceptions will be thrown when an error occurs.
/// </summary>
bool ThrowErrors
This will allow users to catch exceptions with the new error handling implementation.
If the method fails, it will display an error through the console and throw the exception if ThrowErrors
is set to true
.
applicationId
property is the StoreId of your application and it must be provided as a named argument to open the store page on the store app or browser.
Example
await _appRating.PerformRatingOnStoreAsync(applicationId: "id389801252");
Windows
/// <summary>
/// Perform rating without leaving the app.
/// </summary>
Task PerformInAppRateAsync();
This method will raise an in-app review dialog of your current application, otherwise, it will display a console log error announcing that it's not supported.
/// <summary>
/// Perform rating on the current OS store app or open the store page on the browser.
/// </summary>
Task PerformRatingOnStoreAsync();
This method will open the Microsoft Store application on the store page of your current application. Otherwise, it will try to open the store page on the browser.
/// <summary>
/// If set to true, exceptions will be thrown when an error occurs.
/// </summary>
bool ThrowErrors
This will allow users to catch exceptions with the new error handling implementation.
If this method fails, it will display an error through the console and throw the exception if ThrowErrors
is set to true
.
productId
property is the ProductId of your application and it must be provided as a named argument to open the store page on the store app or browser.
Example
await _appRating.PerformRatingOnStoreAsync(productId: "9nblggh5l9xt");
Usage
⚠️ 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 specific number, display a dialogue 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 readonly IAppRating _appRating;
// We are using the Instagram application as an example here
private const string androidPackageName = "com.instagram.android";
private const string iOSApplicationId = "id389801252";
private const string windowsProductId = "9nblggh5l9xt";
public MainPage(IAppRating appRating)
{
InitializeComponent();
_appRating = appRating;
// Set to true if you want to catch exceptions.
_appRating.ThrowErrors = true;
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 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()
{
await MainThread.InvokeOnMainThreadAsync(async () =>
{
# if DEBUG
await _appRating.PerformInAppRateAsync(true);
#else
await _appRating.PerformInAppRateAsync();
#endif
});
Preferences.Set("application_rated", true);
return Task.CompletedTask;
}
private Task RateApplicationOnStore()
{
await MainThread.InvokeOnMainThreadAsync(async () =>
{
try
{
await _appRating.PerformRatingOnStoreAsync(packageName: androidPackageName, applicationId: iOSApplicationId, productId: windowsProductId);
}
catch (Exception ex)
{
// Handle the exception here...
}
});
Preferences.Set("application_rated", true);
return Task.CompletedTask;
}
private void InAppRating_Clicked(object sender, EventArgs e)
{
Task.Run(RateApplicationInApp);
}
private void AppRateOnStore_Clicked(object sender, EventArgs e)
{
if (!Preferences.Get("application_rated", false))
Task.Run(RateApplicationOnStore);
}
}
Sample
Take a look at the AppRatingSample for a fully detailed implementation of this plugin.
Contributions
Please, feel free to open an Issue if you find any bugs or submit a PR.
License
Plugin.Maui.AppRating is licensed under MIT.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net8.0 is compatible. net8.0-android was computed. net8.0-android34.0 is compatible. net8.0-browser was computed. net8.0-ios was computed. net8.0-ios18.0 is compatible. net8.0-maccatalyst was computed. net8.0-maccatalyst18.0 is compatible. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net8.0-windows10.0.19041 is compatible. net9.0 is compatible. net9.0-android was computed. net9.0-android35.0 is compatible. net9.0-browser was computed. net9.0-ios was computed. net9.0-ios18.0 is compatible. net9.0-maccatalyst was computed. net9.0-maccatalyst18.0 is compatible. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net9.0-windows10.0.19041 is compatible. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net8.0
- Microsoft.Maui.Controls (>= 8.0.100)
- Microsoft.Maui.Controls.Compatibility (>= 8.0.100)
-
net8.0-android34.0
- Xamarin.Google.Android.Play.Review.Ktx (>= 2.0.2.4)
-
net8.0-ios18.0
- No dependencies.
-
net8.0-maccatalyst18.0
- No dependencies.
-
net8.0-windows10.0.19041
- No dependencies.
-
net9.0
- Microsoft.Maui.Controls (>= 9.0.82)
-
net9.0-android35.0
- Xamarin.Google.Android.Play.Review.Ktx (>= 2.0.2.4)
-
net9.0-ios18.0
- No dependencies.
-
net9.0-maccatalyst18.0
- No dependencies.
-
net9.0-windows10.0.19041
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories (2)
Showing the top 2 popular GitHub repositories that depend on Plugin.Maui.AppRating:
Repository | Stars |
---|---|
bitfoundation/bitplatform
Build all of your apps using what you already know and love ❤️
|
|
KrawMire/profitocracy
Multi currency personal budget control mobile application following 50-30-20 principle. Created using .NET MAUI
|