Request review in SwiftUI

The requestReview() method of SKStoreReviewController is deprecated in iOS 14 beta. There is a new requestReview(in windowScene: UIWindowScene), but with the App structure in SwiftUI, there is no UIWindowScene. How to request app review?

Accepted Reply

Code Block
import StoreKit
if let windowScene = UIApplication.shared.windows.first?.windowScene { SKStoreReviewController.requestReview(in: windowScene) }

  • This code is now generating a warning: 'windows' was deprecated in iOS 15.0: Use UIWindowScene.windows on a relevant window scene instead

  • @BillHause This should help with the warning.

    private var windowKey: UIWindow? { UIApplication .shared .connectedScenes .flatMap { ($0 as? UIWindowScene)?.windows ?? [] } .first { $0.isKeyWindow } }

Add a Comment

Replies

Have you figured this out yet? Looking for an answer myself.
Code Block
import StoreKit
if let windowScene = UIApplication.shared.windows.first?.windowScene { SKStoreReviewController.requestReview(in: windowScene) }

  • This code is now generating a warning: 'windows' was deprecated in iOS 15.0: Use UIWindowScene.windows on a relevant window scene instead

  • @BillHause This should help with the warning.

    private var windowKey: UIWindow? { UIApplication .shared .connectedScenes .flatMap { ($0 as? UIWindowScene)?.windows ?? [] } .first { $0.isKeyWindow } }

Add a Comment

This might be useful for iOS 15+:

// try getting current scene
guard let currentScene = UIApplication.shared.connectedScenes.first as? UIWindowScene else {
      print("UNABLE TO GET CURRENT SCENE")
      return
}
     
// show review dialog
SKStoreReviewController.requestReview(in: currentScene)
Post not yet marked as solved Up vote reply of Vexy Down vote reply of Vexy
  • Confirming this workes and got rid of the error in iOS 15

Add a Comment

This might be useful for iOS 15+:

// try getting current scene
guard let currentScene = UIApplication.shared.connectedScenes.first as? UIWindowScene else {
      print("UNABLE TO GET CURRENT SCENE")
      return
}
     
// show review dialog
SKStoreReviewController.requestReview(in: currentScene)
Post not yet marked as solved Up vote reply of Vexy Down vote reply of Vexy