UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

How to ask users to review your app using SKStoreReviewController

Swift version: 5.6

Paul Hudson    @twostraws   

Many apps ask users to review their apps, but it’s increasingly common to see dark patterns such as apps pre-screening users so they get sent to the App Store only if they said they like the app.

To avoid this problem in the future, and also to provide a standardized interface that users can trust, iOS 10.3 brought a built-in way to ask users to review the app, and it couldn’t be much easier to use. In iOS 14 this was upgraded to rely on scenes, so it’s important your code makes the review request on an active scene.

But first, some important information:

  1. You request that the system show a review dialog, which means the request might be ignored based on internal logic known only to Apple.
  2. Because the request might be ignored, you should not trigger the request from a user-facing button saying something like “Leave a review” – it might appear to do nothing at all.
  3. When you are in development, requesting a review will always show the review user interface, but you can’t submit an actual review.
  4. When you are using TestFlight to test your app, requesting a review will do nothing at all.

Once you understand those rules, the process really couldn’t be easier. First, add this import to your code:

import StoreKit

Then at some point in your app run this code:

if let scene = UIApplication.shared.connectedScenes.first(where: { $0.activationState == .foregroundActive }) as? UIWindowScene {
    SKStoreReviewController.requestReview(in: scene)
}

That’s it!

Again, you should not call that in response to user input, although if you have any sense you won’t just put it inside viewDidAppear() in your app.

Instead, consider storing a simple run count for your app using UserDefaults, then calling the method after your app has been run 10 times. By that point it’s pretty clear the user keeps coming back to your app, so hopefully you have more chance of getting a positive review!

Hacking with Swift is sponsored by Proxyman

SPONSORED Proxyman: A high-performance, native macOS app for developers to easily capture, inspect, and manipulate HTTP/HTTPS traffic. The ultimate tool for debugging network traffic, supporting both iOS and Android simulators and physical devices.

Start for free

Sponsor Hacking with Swift and reach the world's largest Swift community!

Available from iOS 14.0

Similar solutions…

About the Swift Knowledge Base

This is part of the Swift Knowledge Base, a free, searchable collection of solutions for common iOS questions.

BUY OUR BOOKS
Buy Pro Swift Buy Pro SwiftUI Buy Swift Design Patterns Buy Testing Swift Buy Hacking with iOS Buy Swift Coding Challenges Buy Swift on Sundays Volume One Buy Server-Side Swift Buy Advanced iOS Volume One Buy Advanced iOS Volume Two Buy Advanced iOS Volume Three Buy Hacking with watchOS Buy Hacking with tvOS Buy Hacking with macOS Buy Dive Into SpriteKit Buy Swift in Sixty Seconds Buy Objective-C for Swift Developers Buy Beyond Code

Was this page useful? Let us know!

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.