Skip to content

Commit

Permalink
Refactor and update platform support and documentation
Browse files Browse the repository at this point in the history
Updated README.md to reflect .NET 8+ support for iOS, Android, MacCatalyst, and Windows, and removed outdated platform information. Changed UWP method signatures to return `Task<bool>` for `OpenStoreListing` and `OpenStoreReviewPage`. Updated Android setup instructions in README.md to remove outdated steps. Refactored `CrossStoreReview.shared.cs` and `StoreReviewImplementation` files for modern C# syntax and improved nullability. Simplified `IStoreReview.shared.cs` interface. Updated `StoreReview.Plugin.csproj` with correct metadata. Improved exception handling and logging across all platforms.
  • Loading branch information
jamesmontemagno committed Dec 1, 2024
1 parent 24a1f2e commit c1fffdc
Show file tree
Hide file tree
Showing 7 changed files with 319 additions and 402 deletions.
37 changes: 5 additions & 32 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
## Store Review Plugin for .NET MAUI, Windows, & Xamarin
## Store Review Plugin for .NET MAUI, iOS, Android, MacCatalyst, Windows

**Platform Support**

|Platform|Version|
| ------------------- | :------------------: |
|Xamarin.iOS|iOS 7+|
|Xamarin.tvOS|All|
|Xamarin.Android|API 10+|
|UWP|API 10+|
|.NET 6+ | iOS/Android/Mac/Windows/MAUI |
|macOS|All|
Support for .NET 8+ for iOS/Android/MacCatalyst/Windows/MAUI


### Build Status
Expand All @@ -31,7 +24,7 @@ UWP: This is the Store ID: You can find the link to your app's Store listing on
/// Opens the store listing.
/// </summary>
/// <param name="appId">App identifier.</param>
void OpenStoreListing(string appId);
Task<bool> OpenStoreListing(string appId);
```

#### Open to Review Page
Expand All @@ -42,7 +35,7 @@ Launches app directly to Review Page if possible
/// Opens the store review page.
/// </summary>
/// <param name="appId">App identifier.</param>
void OpenStoreReviewPage(string appId);
Task<bool> OpenStoreReviewPage(string appId);
```

#### Request In-App Review
Expand All @@ -60,7 +53,7 @@ Read for Android: [In-app reviews for your Android apps](https://devblogs.micros
Task<ReviewStatus> RequestReview(bool testMode)
```

If you are on .NET 6 Windows you will need to set the Window handle before calling the method:
If you are on .NET 8 Windows you will need to set the Window handle before calling the method:

```csharp
#if WINDOWS
Expand All @@ -71,26 +64,6 @@ If you are on .NET 6 Windows you will need to set the Window handle before calli

Test mode is only used on Android.

### Android setup

Ensure that you follow the [Xamarin.Essentials setup steps](https://docs.microsoft.com/xamarin/essentials/get-started?WT.mc_id=friends-0000-jamont). And follow the steps below if you linker behavior is not set to `Don't Link`.

#### Android code shrinker (Proguard & r8)

If you use the plugin with `Link SDK assemblies only`/`Link all`, you have to do the following:

1. Create a `proguard.txt` file in your android project and add the following:

```
-keep class com.google.android.play.core.common.PlayCoreDialogWrapperActivity
-keep class com.google.android.play.core.review.** { *; }
-keep class com.google.android.play.core.tasks.** { *; }
```

2. Include it to your project
3. Properties > Build Action > ProguardConfiguration
4. Go to you Android project options and set your `Code Shrinker` to `ProGuard` or `r8`

### Testing & Debugging issues

#### iOS
Expand Down
76 changes: 37 additions & 39 deletions src/StoreReview.Plugin/CrossStoreReview.shared.cs
Original file line number Diff line number Diff line change
@@ -1,51 +1,49 @@
using Plugin.StoreReview.Abstractions;
using System;

namespace Plugin.StoreReview
namespace Plugin.StoreReview;

public enum ReviewStatus
{
public enum ReviewStatus
{
Succeeded,
Error,
CanceledByUser,
NetworkError,
Unknown
}
/// <summary>
/// Cross platform StoreReview implemenations
/// </summary>
public class CrossStoreReview
{
static Lazy<IStoreReview> implementation = new Lazy<IStoreReview>(() => CreateStoreReview(), System.Threading.LazyThreadSafetyMode.PublicationOnly);
Succeeded,
Error,
CanceledByUser,
NetworkError,
Unknown
}
/// <summary>
/// Cross platform StoreReview implemenations
/// </summary>
public class CrossStoreReview
{
static readonly Lazy<IStoreReview> implementation = new(() => CreateStoreReview(), LazyThreadSafetyMode.PublicationOnly);

/// <summary>
/// Gets if the plugin is supported on the current platform.
/// </summary>
public static bool IsSupported => implementation.Value == null ? false : true;
/// <summary>
/// Gets if the plugin is supported on the current platform.
/// </summary>
public static bool IsSupported => implementation.Value != null;

/// <summary>
/// Current plugin implementation to use
/// </summary>
public static IStoreReview Current
{
get
{
var ret = implementation.Value;
return ret is null ? throw NotImplementedInReferenceAssembly() : ret;
}
/// <summary>
/// Current plugin implementation to use
/// </summary>
public static IStoreReview Current
{
get
{
var ret = implementation.Value;
return ret is null ? throw NotImplementedInReferenceAssembly() : ret;
}
}

static IStoreReview CreateStoreReview()
{
static IStoreReview CreateStoreReview()
{
#if ANDROID || IOS || MACCATALYST || MACOS || WINDOWS
return new StoreReviewImplementation();
return new StoreReviewImplementation();
#else
return null;
return null!;
#endif
}
}

internal static Exception NotImplementedInReferenceAssembly() =>
new NotImplementedException("This functionality is not implemented in the portable version of this assembly. You should reference the NuGet package from your main application project in order to reference the platform-specific implementation.");

internal static Exception NotImplementedInReferenceAssembly() =>
new NotImplementedException("This functionality is not implemented in the portable version of this assembly. You should reference the NuGet package from your main application project in order to reference the platform-specific implementation.");

}
}
41 changes: 19 additions & 22 deletions src/StoreReview.Plugin/IStoreReview.shared.cs
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
using System.Threading.Tasks;
namespace Plugin.StoreReview.Abstractions;

namespace Plugin.StoreReview.Abstractions
/// <summary>
/// Interface for StoreReview
/// </summary>
public interface IStoreReview
{
/// <summary>
/// Interface for StoreReview
/// </summary>
public interface IStoreReview
{
/// <summary>
/// Opens the store listing.
/// </summary>
/// <param name="appId">App identifier.</param>
Task<bool> OpenStoreListing(string appId);
/// <summary>
/// Opens the store listing.
/// </summary>
/// <param name="appId">App identifier.</param>
Task<bool> OpenStoreListing(string appId);

/// <summary>
/// Opens the store review page.
/// </summary>
/// <param name="appId">App identifier.</param>
Task<bool> OpenStoreReviewPage(string appId);
/// <summary>
/// Opens the store review page.
/// </summary>
/// <param name="appId">App identifier.</param>
Task<bool> OpenStoreReviewPage(string appId);

/// <summary>
/// Requests an app review.
/// </summary>
Task<ReviewStatus> RequestReview(bool testMode);
}
/// <summary>
/// Requests an app review.
/// </summary>
Task<ReviewStatus> RequestReview(bool testMode);
}
16 changes: 9 additions & 7 deletions src/StoreReview.Plugin/StoreReview.Plugin.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,21 @@
<Version>1.0.0.0</Version>

<!-- NuGet -->
<Authors>author</Authors>
<Copyright>Copyright © author and contributors</Copyright>
<Authors>James Montemagno</Authors>
<Copyright>Copyright Refractored LLC and contributors</Copyright>
<IsPackable>True</IsPackable>
<PackageProjectUrl>https://github.com/jfversluis/Plugin.Maui.Feature</PackageProjectUrl>
<RepositoryUrl>https://github.com/jfversluis/Plugin.Maui.Feature</RepositoryUrl>
<PackageId>Plugin.StoreReview</PackageId>
<PackageProjectUrl>https://github.com/jamesmontemagno/storereviewplugin</PackageProjectUrl>
<RepositoryUrl>https://github.com/jamesmontemagno/storereviewplugin</RepositoryUrl>
<RepositoryType>git</RepositoryType>
<PackageTags>dotnet-maui;maui;plugin;</PackageTags>
<PackageTags>dotnet-maui;maui;plugin;review;storereview;android;ios;windows;maccatalyst</PackageTags>
<IncludeSymbols>True</IncludeSymbols>
<PublishRepositoryUrl>true</PublishRepositoryUrl>
<EmbedUntrackedSources>true</EmbedUntrackedSources>
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
<Title>.NET MAUI Feature Plugin</Title>
<Description>Plugin.Maui.Feature provides the ability to do this amazing thing in your .NET MAUI application.</Description>
<Title>Store Review Plugin for .NET MAUI, iOS, Android, MacCatalyst, and Windows</Title>
<Description>Easily request a review or open the store page for your app.</Description>
<Summary>Easily request a review or open the store page for your app.</Summary>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<PackageRequireLicenseAcceptance>True</PackageRequireLicenseAcceptance>
<DebugType>portable</DebugType>
Expand Down
Loading

0 comments on commit c1fffdc

Please sign in to comment.