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

Introduction to StoreKit and Apple App Store policies

 
I will write down 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. User can also choose to write review for iOS and macOS apps.

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

 
About Summery of Ratings

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

 
Developer can reset your app’s summary rating with release a new version of app.

 
Right way to ask for Ratings and Reviews

 
Developer can ask users to rate and review your app at appropriate times when users are most likely to feel satisfaction with app 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.

 
Developer can prompt for ratings maximum by three times in a 365-day period.

 
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. 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, review request view is always displayed so that you can test it on your device. However, this method will not be called when you distribute your app using TestFlight.

 
When you call this method in your shipping app and a review request view will be presented and the operating system will handles the entire process of presentation.

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

 
As we have learn from above content of the post operating system will only display 3 prompts for review in 365 days period.

 
That means we have to insatiate prompt at right interval as we have 3 chance to show prompt for 365 days period.

 
Step 01: Import Store Kit in Header

 

import StoreKit

 
Step 02: Create Function called AppReviewer with 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 viewDidLoad function of your app where you want to display 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 display review prompt at quick successions and on wrong intervals.

 
Hope it helps,

 
Thanks & Regards
Mandar Apte

Leave a Reply

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