Skip to content

Commit

Permalink
Update StoreReviewImplementation.uwp.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesmontemagno authored Mar 9, 2024
1 parent 8555041 commit f9dd32b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/StoreReview.Plugin/StoreReviewImplementation.uwp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public void OpenStoreReviewPage(string appId) =>
OpenUrl($"ms-windows-store://review/?ProductId={appId}");

#if NET6_0_OR_GREATER
public static object WindowObject { get; set; }
public static object Window { get; set; }
#endif
/// <summary>
/// Requests an app review.
Expand All @@ -44,9 +44,11 @@ public async Task<ReviewStatus> RequestReview(bool testMode)
var context = StoreContext.GetDefault();

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

var hwnd = WinRT.Interop.WindowNative.GetWindowHandle(Window);

WinRT.Interop.InitializeWithWindow.Initialize(context, hwnd);
#endif

Expand All @@ -65,6 +67,12 @@ public async Task<ReviewStatus> RequestReview(bool testMode)
Debug.WriteLine(ex);
return ReviewStatus.Error;
}
finally
{
#if NET6_0_OR_GREATER
Window = null;
#endif
}
}

void OpenUrl(string url)
Expand Down

0 comments on commit f9dd32b

Please sign in to comment.