When I use SKStoreReviewController.requestReview()
to request a review from the Scene Delegate in my SwiftUI application, I get the following message:
Error in UIKit client: -[UIWindow setScreen:] should not be called if the client adopts UIScene lifecycle. Call -[UIWindow setWindowScene:] instead.
.
I am using the following code in the scene delegate to request the review:
if let windowScene = scene as? UIWindowScene {
if UserDefaults.standard.integer(forKey: "launchCount") == 10 {
let window = UIWindow(windowScene: windowScene)
window.rootViewController = UIHostingController(rootView: homeView)
self.window = window
window.makeKeyAndVisible()
if #available(iOS 14, *) {
SKStoreReviewController.requestReview(in: windowScene)
}
else {
SKStoreReviewController.requestReview()
}
}
}
This code is inside the scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions)
method of the Scene Delegate. The method for iOS 14 is working where the review is being requested from the UIWindowScene
, but the method for earlier versions is not working and returns the message specified previously. Is there any way to fix this? Thanks in advance for all the help.