Using SKStoreReviewController API to prompt users to write reviews for your App.

Introduction to StoreKit and Apple App Store policies

I will write down a few concepts & ideas to help you understand how 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 when they are most likely to feel satisfied, such as when they have 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 your app 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 must initiate 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() {
        let currentCount = UserDefaults.standard.integer(forKey: Constants().launchCount)
        UserDefaults.standard.set(currentCount+1, forKey: Constants().launchCount)
        if currentCount > 0 {
            if currentCount % 10 == 0 {
                if let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene {
                    SKStoreReviewController.requestReview(in: scene)
                }
            }
        }
    }

Important Note:
As you can see above, the appStoreKitReview() function will be called when the user launches the app from the home screen 10 times, 20 times, 30 times, and 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.

        self.appStoreKitReview()
    }

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

I hope this helps,

Thanks & Regards
Mandar Apte

Published by Mandar Apte

Mandar is a Mumbai-based multi-disciplinary designer with UX/UI, Logo, Symbol, and Brand Identity design expertise. He currently runs his Mudrkashar Linguistic Apple iPhone, iPad, and Mac app business in the heart of Mumbai city.

Leave a comment

Leave a Reply