복붙노트

[SWIFT] SKStore 검토 컨트롤러가 제출 된 경우 가능 결정입니다.

SWIFT

SKStore 검토 컨트롤러가 제출 된 경우 가능 결정입니다.

해결법


  1. 1.여기 제시 한 경우 I 감지 방법이다.

    여기 제시 한 경우 I 감지 방법이다.

    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)
        }
    }
    
  2. from https://stackoverflow.com/questions/43268014/is-it-possible-determine-if-skstorereviewcontroller-has-been-presented by cc-by-sa and MIT license