Skip to content

Commit

Permalink
Simplified internal implementation for method requestReview
Browse files Browse the repository at this point in the history
  • Loading branch information
Jinya committed Apr 21, 2022
1 parent 5be6d41 commit b865189
Showing 1 changed file with 3 additions and 16 deletions.
19 changes: 3 additions & 16 deletions Sources/AppStoreReviewManager/AppStoreReviewManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,24 +43,11 @@ public struct AppStoreReviewManager {
@available(iOS 10.3, *)
public static func requestReviewInApp() {
let block = {
if #available(iOS 15.0, *) {
if #available(iOS 14.0, *) {
guard let windowScene = UIApplication.shared.connectedScenes
.filter({ $0.activationState == .foregroundActive })
.compactMap({ $0 as? UIWindowScene })
.first
.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene
else {
assertionFailure("AppStoreReviewManager can't find a foreground active window scene of the app!")
return
}
SKStoreReviewController.requestReview(in: windowScene)
} else if #available(iOS 14.0, *) {
guard let windowScene = UIApplication.shared.connectedScenes
.compactMap({ $0 as? UIWindowScene })
.flatMap({ $0.windows })
.first(where: { $0.isKeyWindow })?
.windowScene
else {
assertionFailure("AppStoreReviewManager can't find a key window of the app!")
debugPrint("AppStoreReviewManager couldn't find a foreground active window scene to request review alert!")
return
}
SKStoreReviewController.requestReview(in: windowScene)
Expand Down

0 comments on commit b865189

Please sign in to comment.