Skip to content

Commit

Permalink
Merge c1fffdc into ae458a6
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmontemagno authored Dec 1, 2024
2 parents ae458a6 + c1fffdc commit 424cfc0
Show file tree
Hide file tree
Showing 99 changed files with 391 additions and 16,473 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
88 changes: 40 additions & 48 deletions src/StoreReview.Plugin/CrossStoreReview.shared.cs
Original file line number Diff line number Diff line change
@@ -1,57 +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;
if (ret == null)
{
throw NotImplementedInReferenceAssembly();
}
return 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()
{
#if NETSTANDARD1_0 || NETSTANDARD2_0
return null;
#else
#pragma warning disable IDE0022 // Use expression body for methods
return new StoreReviewImplementation();
#pragma warning restore IDE0022 // Use expression body for methods
static IStoreReview CreateStoreReview()
{
#if ANDROID || IOS || MACCATALYST || MACOS || WINDOWS
return new StoreReviewImplementation();
#else
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>
void 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>
void 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);
}
Loading

0 comments on commit 424cfc0

Please sign in to comment.