Skip to content

Commit

Permalink
Add window handle tht needs to be passed in.
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmontemagno committed Mar 8, 2024
1 parent 6a18f50 commit 8555041
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 186 deletions.
11 changes: 10 additions & 1 deletion src/StoreReview.Plugin/StoreReviewImplementation.uwp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,9 @@ public void OpenStoreListing(string appId) =>
public void OpenStoreReviewPage(string appId) =>
OpenUrl($"ms-windows-store://review/?ProductId={appId}");


#if NET6_0_OR_GREATER
public static object WindowObject { get; set; }
#endif
/// <summary>
/// Requests an app review.
/// </summary>
Expand All @@ -41,6 +43,13 @@ public async Task<ReviewStatus> RequestReview(bool testMode)

var context = StoreContext.GetDefault();

#if NET6_0_OR_GREATER
if(WindowObject is null)
throw new NullReferenceException("WindowObject is null. Please set the WindowObject property before calling RequestReview.");
var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(WindowObject);
WinRT.Interop.InitializeWithWindow.Initialize(context, hwnd);
#endif

var result = await context.RequestRateAndReviewAppAsync();
return result.Status switch
{
Expand Down
Loading

0 comments on commit 8555041

Please sign in to comment.