What is Apple Store Kit Framework, and how to write code for SKStoreReviewController API which will prompt users to write reviews for your App while using your app & without leaving your app

Introduction to StoreKit and Apple App Store policies

I will write down a few concepts & ideas to help you understand to implement StoreKit app review functionality in your app using Xcode.

Important Points to remember

You can ask your users to rate your app on a scale of 1 to 5 stars. Users can also choose to write reviews for iOS and macOS apps.

Developers can view, sort and respond to reviews in iTunes Connect.

About Summery of Ratings

Every App Store app has one summary rating on the product page, specific to each territory on the App Store.

The developer can reset your app’s summary rating by releasing a new version of the app.

The right way to ask for Ratings and Reviews

The developer can ask users to rate and review your app at appropriate times when users are most likely to feel satisfied, e.g. when they’ve completed an action, level or task.

This will give users an easy way to provide feedback on the App Store without leaving your app.

The developer can prompt for rating a maximum of three times in 365 days.

Users will submit a rating through the standardised prompt.

Presenting the Review Prompt

Although you should call this method when it makes sense in the user experience flow of your app, the actual display of a rating/review request view is governed by App Store policy. In addition, because this method may or may not present an alert, it’s not appropriate to call it in response to a button tap or other user action.

When you call this method in development mode, the review request view is always displayed so that you can test it on your device. However, this method will not be called when distributing your app using TestFlight.

When you call this method in your App Store-published app, a review request view will be presented, and the operating system will handle the entire presentation process.

Now we will have a look at the code & how to implement it,

As we have learned from the above content, most operating systems will only display three prompts for review in 365 days.

That means we have to insatiate prompts at the proper interval as we have three chances to show prompts for 365 days.

Step 01: Import Store Kit in Header

import StoreKit

Step 02: Create a Function called AppReviewer with the correct logic

    func appStoreKitReview() {
        if #available( iOS 10.3,*){
            // Get current number of times app has been launched
            let currentCount = UserDefaults.standard.integer(forKey: "launchCount")

            // Increment received number by one
            UserDefaults.standard.set(currentCount+1, forKey:"launchCount")

            // Save changes to disk
            UserDefaults.standard.synchronize()

            // Instantiate App Store Review
            if currentCount > 0 {
                if currentCount % 10 == 0 {
                    SKStoreReviewController.requestReview()
                }
            }
        }
    }

Important Note: As you can see above appStoreKitReview() function will be called when user launch app from home screen 10 times, 20 times, 30 times so on so forth

Step 03: Call that function in the viewDidLoad part of your app where you want to display the review prompt

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.

        appStoreKitReview()
    }

Important Note: Don’t add this code to multiple view controllers as it may increment code twice & will show the review prompt at quick successions and on wrong intervals.

Hope it helps,

Thanks & Regards
Mandar Apte

Mandar Apte

This website contains a design articles blog by Mandar Apte. He writes and shares his iOS development, graphic, web, & animation film design experience through articles. Mandar is Mumbai based multi-disciplinary designer with expertise in UI, UX, Logo, Symbol, and Brand Identity design. He is an alumnus of Sir J. J. Institute of Applied Art, Mumbai. He currently runs his studio in the heart of the city of Mumbai.

Leave a Reply

Your email address will not be published. Required fields are marked *