2

I've included my code below. If there's no wifi and no cellular service, the app freezes. If I turn cellular off altogether, it prints ""Not reachable", which is expected, and the app works fine. But if there's no service and cellular is on, (for instance, in the subway), it says "reachable via cellular" and I can't interact with the app. It's just frozen, even though that code is on the background thread.

 let reachability = Reachability()

@IBAction func rateButtonAction(_ sender: Any) {
    if #available(iOS 10.3, *) {


        DispatchQueue.global(qos: .background).async {
                if self.reachability?.connection == .wifi {
                    print("Reachable via WiFi")
                    SKStoreReviewController.requestReview()
                } else if self.reachability?.connection == .cellular {
                    print("Reachable via Cellular")
                    SKStoreReviewController.requestReview()
                } else if self.reachability?.connection == .none {
                    print("Not reachable")
                } else {
                    print("Not reachable")
                }
            }
    } else {
        print("Rate didn't work")
    }
}
c0nman
  • 189
  • 1
  • 12
  • 2
    Don't call `requestReview()` on a background thread. This answer here addresses the reason why: https://stackoverflow.com/questions/52671404/skstoreproductviewcontroller-initialization-on-non-main-thread/52672666#52672666 – CodeBender Feb 03 '19 at 16:22
  • 1
    This is not the best solution for getting reviews or ratings from the users! Use the App Store URL instead. Because `requestReview` does not calls every time. See the Apple’s recommendations – Mannopson Feb 03 '19 at 16:25
  • 2
    Apple's recommendation is to use `requestReview`; it throttles the number of review requests the user sees and doesn't ask them to review if they have already done so – Paulw11 Feb 03 '19 at 19:56
  • 1
    Don't delete and repost. – jscs Feb 03 '19 at 21:57

0 Answers0