SKStoreReviewController.requestReview(in:) and SwiftUI's Scene

In the latest iOS, the keyWindow automatic version of SKStoreReviewController.requestReview() got deprecated in favour of a new SKStoreReviewController.requestReview(in windowScene: UIWindowScene) version.
Then, in the latest SwiftUI, the UIWindowScene got removed in favour of a new SwiftUI some Scene family.
How do I efficiently tie the two together in a View without resorting to the key UIWindow?

Accepted Reply

I don't think this is possible yet in a pure SwiftUI way. I raised a Technical Support Incident for this as I too needed to know how and the solution I received from Apple is below:

Code Block swift
if let windowScene = UIApplication.shared.connectedScenes.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene {
SKStoreReviewController.requestReview(in: windowScene)
}

I was hoping the active scene would be available as an @Environment value, but alas no. My app uses the SwiftUI lifecycle and so I prefer not to fall back to UIApplication like this.

Replies

I don't think this is possible yet in a pure SwiftUI way. I raised a Technical Support Incident for this as I too needed to know how and the solution I received from Apple is below:

Code Block swift
if let windowScene = UIApplication.shared.connectedScenes.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene {
SKStoreReviewController.requestReview(in: windowScene)
}

I was hoping the active scene would be available as an @Environment value, but alas no. My app uses the SwiftUI lifecycle and so I prefer not to fall back to UIApplication like this.
Thank you for your answer, ddijitall. We are in the same boat. Although the features are working and I understand why they go that route, it lacks polishing.

Cheers and happy holidays!