以下是我如何檢測它是否已被呈現。
private static func checkIfShownSKStoreReviewController(_ iteration: Int, originalWindowCount: Int) {
let windows = UIApplication.shared.windows
if windows.count > originalWindowCount {
let window = windows[1]
if window.className == "UITextEffectsWindow" || window.className == "UIRemoteKeyboardWindow" {
print("Shown SKVC iteration: \(iteration)")
//Do logic stuff like saving to your database
return
}
}
if iteration > 2000 {
print("checkIfShownSKStoreReviewController: timeout, bailing \(iteration)")
return
}
runThisAfterDelay(seconds: 0.02, after: {
checkIfShownSKStoreReviewController(iteration + 1, originalWindowCount: originalWindowCount)
})
}
private static func runThisAfterDelay(seconds seconds: Double, after:() ->()) {
let time = dispatch_time(DISPATCH_TIME_NOW, Int64(seconds * Double(NSEC_PER_SEC)))
dispatch_after(time, dispatch_get_main_queue(), after)
}
static func showReview() {
print("Showing AppStore Review")
if #available(iOS 10.3, *) {
SKStoreReviewController.requestReview()
checkIfShownSKStoreReviewController(0, originalWindowCount: UIApplication.shared.windows.count)
}
}
你說你不想使用UserDefaults但即使有一個方法來確定是否SKStore查看控制器目前提出或已經提出以前那麼你將如何保存的價值呢? 但我會檢查[this](http://stackoverflow.com/questions/43075515/how-to-use-requestreview-skstorereviewcontroller-to-show-review-popup-in-the)的答案。 –
[SKStoreReviewController如何檢測到用戶已關閉此應用程序(RTA)設置或3次限制的可能重複已達到?](https://stackoverflow.com/questions/42533520/skstorereviewcontroller-how-to-detect -hat-user-has-turn-off-rate-this-app-rt) –