Skip to content

Commit

Permalink
Updated iPhone review to the newer SKStoreReviewController
Browse files Browse the repository at this point in the history
* As mentioned in #32 , the older SKStoreReviewController is deprecated and we should be using the newer ones recommended by apple.
* I followed the code recommended in the [Apple Forums](https://developer.apple.com/forums/thread/652157?answerId=653723022#653723022) in order to figure out the solution

**Testing**
------
* Tested in iPhone 8 Simulator running iOS 15.2
* Created a blank native app in Xamarin iOS and put in the code as you can see in the screenshots and i was able to see the review popup successfully without any exceptions
  • Loading branch information
saamerm committed Jan 27, 2022
1 parent 98778f4 commit 7d53a5b
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/StoreReview.Plugin/StoreReviewImplementation.apple.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using System.Threading.Tasks;
#if !__MACOS__
using UIKit;
using System.Linq;
#endif
using StoreKit;

Expand Down Expand Up @@ -79,6 +80,15 @@ public Task RequestReview(bool testMode)
#if __IOS__
if (IsiOS103)
{
if (IsiOS14)
{
var windowScene = UIApplication.SharedApplication.ConnectedScenes.ToArray<UIScene>()?.First(x => x.ActivationState == UISceneActivationState.ForegroundActive) as UIWindowScene;
if (windowScene != null)
{
SKStoreReviewController.RequestReview(windowScene);
return;
}
}
SKStoreReviewController.RequestReview();
}
#elif __MACOS__
Expand All @@ -105,6 +115,7 @@ internal static Version ParseVersion(string version)

#if __IOS__
bool IsiOS103 => UIDevice.CurrentDevice.CheckSystemVersion(10, 3);
bool IsiOS14 => UIDevice.CurrentDevice.CheckSystemVersion(14, 0);
#endif

}
Expand Down

0 comments on commit 7d53a5b

Please sign in to comment.