Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

258
Visualizações
requestReview() deprecated in iOS 14, Alternative for xamarin.forms?

I'm using

SKStoreReviewController.RequestReview ();

in a dependency service for Xamarin.Forms. However this is now deprecated from iOS 14. And I want to know how to integrate with the new UIWindowScene

requestReview(in windowScene: UIWindowScene)

in Xamarin.Forms

over 4 years ago · Santiago Trujillo
2 Respostas
Responde à pergunta

0

First, you can try to add SKStoreReviewController.RequestReview(Window.WindowScene) in the FinishedLaunching method of your xxx.ios->AppDelegate.cs; start the project to see if it is correct.

If the above method goes wrong, using DependencyService is the right way to go.

Here is the interface code:

 public interface MyInterface
{
     void RequestReview();
}

Here is the implementation method of the interface in ios:

[assembly: Dependency(typeof(MyInterfaceImpl))]
namespace App19.iOS
{
    public class MyInterfaceImpl : MyInterface
    {
        public void RequestReview()
        {
           var myv = UIDevice.CurrentDevice.CheckSystemVersion(14, 0);
            if (myv)
            {
                UIWindow window = UIApplication.SharedApplication.Delegate.GetWindow();
            SKStoreReviewController.RequestReview(window.WindowScene);
            }
            else 
            {
                SKStoreReviewController.RequestReview();
            }
        }
    }
}

You can call it in the OnStart method inside APP.xaml.cs:

 protected override void OnStart()
    {
        if (Device.RuntimePlatform == Device.iOS)
        {
            DependencyService.Get<IReviewService>().RequestReview();
        }
    }
over 4 years ago · Santiago Trujillo Relatório

0

I might have a solution:

using StoreKit;
using UIKit;

public void RequestReview(){
    var scene = UIApplication.SharedApplication.KeyWindow.WindowScene;

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

    SKStoreReviewController.RequestReview(scene);
}

I've found multiple ways of getting the current scene and they both worked when I tested them:

var scene = UIApplication.SharedApplication.KeyWindow.WindowScene;

var alsoScene = UIApplication.SharedApplication.Delegate.GetWindow()?.WindowScene;

You can read more about the difference between the two in this issue

The complete solution where you check the iOS version in order to call the right thing might look like this

using StoreKit;
using UIKit;

public void RequestReview()
{
    var isIos14OrAbove = UIDevice.CurrentDevice.CheckSystemVersion(14, 0);
    if (isIos14OrAbove)
    {
        var scene = UIApplication.SharedApplication.KeyWindow.WindowScene;

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

        SKStoreReviewController.RequestReview(scene);
    }
    else
    {
        SKStoreReviewController.RequestReview();
    }
}

Hope this helps.

over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda