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 } }
Replies
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 } }
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)
-
Confirming this workes and got rid of the error in iOS 15
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)