SKStoreReviewController how to detect that user has turned off Rate This App (RTA) in settings or 3 times limit has reached?

匆匆过客 提交于 2019-12-02 20:47:56
Nikola Lajic

Preamble

Asking users if they like the app might lead to your app being rejected. Here is an example: https://twitter.com/pietbrauer/status/791883047373246464

In case the link dies here is an excerpt of Apples response:

3.2.2 ... your app includes content and features that can manipulate the user reviews or chart rankings on the App Store. Specifically, your app filters user reviews and only directs users who intend to rate your app 4 - 5 stars to complete a rating on the App Store...

I personally believe that this can be a valid tactic if you genuinely try to resolve the users issue, and still give them an opportunity to leave a review afterwards, but the question remains if Apple will see it that way.

Possible solution

  1. Show popup asking the user if they enjoy/like/etc using the app.
  2. Try using [SKStoreReviewController requestReview] to get a review.
  3. Check if the number of windows has changed, indicating that a popup has been shown. The caveat here is that this is not 100% reliable since some other event can cause the number of windows to change.
  4. If the number of windows stays the same use deep linking to forward the user to the app store. The docs for SKStoreReviewController suggest using action=write-review as a query parameter to go directly to the reviews page.

Here is a simple implementation:

// make sure we the current iOS version supports in app reviews
if ([SKStoreReviewController class])
{
    NSUInteger windowCount = [UIApplication sharedApplication].windows.count;
    [SKStoreReviewController requestReview];

    // give the review controller some time to display the popup
    dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 1 * NSEC_PER_SEC), dispatch_get_main_queue(), ^{
        if (windowCount < [UIApplication sharedApplication].windows.count)
        {
            // assume review popup showed instead of some other system alert
            // for example show "thank you"
        }
        else
        {
            // open app store to leave review
            NSURL *reviewUrl = [NSURL URLWithString:@"{your-app-url}?action=write-review"];
            [[UIApplication sharedApplication] openURL:reviewUrl];
        }
    });
}

Note: I have not submitted this code to the App Store, so this is only theoretical.

Well, you could try to fire the request and see but as long as there's no callback as well as no other official way how to detect whether the rating alert has been displayed at the time you call the requesting method.

There is a way around however – one of the StoreKit classes can be swizzled so you can observe when the Rating dialog is opened.

UIWindow-inspecting ways mentioned around may be useful as well, but swizzling on a method call is probably more reliable.

You can also use some rating managers like AppRating available as a pod, which manage the stuff for you, but only on a naive level by counting the calls and remembering it.

Grzegorz Krukowski

In official Apple example that is here:

https://developer.apple.com/documentation/storekit/skstorereviewcontroller/requesting_app_store_reviews?language=objc

They are doing it this way:

let twoSecondsFromNow = DispatchTime.now() + 2.0
DispatchQueue.main.asyncAfter(deadline: twoSecondsFromNow) { [navigationController] in
    if navigationController?.topViewController is ProcessCompletedViewController {
        SKStoreReviewController.requestReview()
        UserDefaults.standard.set(currentVersion, forKey: UserDefaultsKeys.lastVersionPromptedForReviewKey)
    }
}

I have no idea why they couldn't simply return a BOOL from SKStoreReviewController.requestReview().

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!