Swift: SKStore Implementation

Rich Mucha
Nov 4 · 2 min read

Welcome to another instalment to help you develop faster and more efficient. In this tutorial you will quickly implement app store reviews in your application using SKStoreReviewController.

SKStoreReviewController

From iOS10.3, Apple implemented an API that provides a popup that will allow users to leave reviews on the App Store with minimal effort:

Implementation

Going to make it very simple for you, with a simple helper implementation, that you can copy and paste into your application.

SKStoreReviewHelper example

The first method in this helper struct is the count increment:

static func incrementAppOpenedCount() {
appOpenCount += 1
}

You should call this in a place in the app that is not going to increment too fast, for example in the app delegate:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool

by calling: SKStoreReviewHelper.incrementAppOpenedCount()

When you do increment be sure that you are not going to annoy the user with too many requests, because it will defeat the object of reviewing and probably give you negative results.

Presentation

static func checkAndAskForReview() {
switch appOpenCount {
case 10, 50:
SKStoreReviewController.requestReview()
incrementAppOpenedCount()
case _ where appOpenCount%100 == 0:
SKStoreReviewController.requestReview()
incrementAppOpenedCount()
default: break;
}
}

This helper will validate the appOpenCount with the values you want to set, in this particular setup the helper will present the review at 10, 50 and then multiples of 100.

You should call: SKStoreReviewHelper.checkAndAskForReview() when you feel it is the right time to ask the user, just ensure that if it is on a controller loading methods that it is after the view has completely loaded: viewDidAppear would be ideal; unless of course you are want it to happen after a action.

That’s pretty much it, very simple and you will not have to think about it again.

Thanks for reading and let me know your thoughts, share your thoughts and send to friends/collegues. Also check out my other tutorials that will make your life much simpler 😁.

Happy dev’ing 😀

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade