Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use the new requestReview(in: uiWindowScene) for iOS 14 and above #32

Closed
michaldivis opened this issue Jan 27, 2022 · 4 comments · Fixed by #33
Closed

Use the new requestReview(in: uiWindowScene) for iOS 14 and above #32

michaldivis opened this issue Jan 27, 2022 · 4 comments · Fixed by #33

Comments

@michaldivis
Copy link

Feature Request: new iOS requestReview(in:)

Use the new requestReview(in: uiWindowScene) that's available since iOS 14.0.

Why

The implementation currently used in this plugin (requestReview()) is deprecated since iOS 14.0.

Proposal

I'd like to propose using the new variation of the requestReview(in: uiWindowScene) method.

It shouldn't be a big change (hopefully), I've already tried to implement the new way and it seems to be working.

Here's a possible implementation (I'm not iOS expert so I apologize if the implementation shown in the examples is wrong):

using StoreKit;
using UIKit;

public void RequestReview()
{
    var isIos14OrAbove = UIDevice.CurrentDevice.CheckSystemVersion(14, 0);
    if (isIos14OrAbove)
    {
        var scene = UIApplication.SharedApplication.KeyWindow.WindowScene;
        
        //another option (I'm not sure which to use):
        //var scene = UIApplication.SharedApplication.Delegate.GetWindow()?.WindowScene;

        if (scene is null)
        {
            //handle the scene being null here
            return;
        }

        SKStoreReviewController.RequestReview(scene);
    }
    else
    {
        SKStoreReviewController.RequestReview();
    }
}
@saamerm
Copy link
Contributor

saamerm commented Jan 27, 2022

@michaldivis Good catch!

@michaldivis
Copy link
Author

@saamerm Wow, that was really quick! Thanks so much!

@jamesmontemagno
Copy link
Owner

I think if they aren't using scenes then we use the old mechanism
i am cool with that.

@jamesmontemagno
Copy link
Owner

I see that addressed in PR nice!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants