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?
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?
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:
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.
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.