Asking user to rate or review app in iOS – Swift Tutorial

In this post, we will learn how we can use iOS sdk Storekit framework to ask for app store rating. With the help of SKStoreReviewController we can show user a pop up to rate our iOS app, that’s too without leaving the app. Earlier, we open the app store app and ask user for app rating. So let us start using Storekit framework to let user ask for app store rating.

Things to keep in mind while adding app rating pop up using SKStoreReviewController

  1. App rating alert will be shown 3 times during a period of 365 days.
  2. Don’t trigger the app rating alert on a button click, because it may or may not show the alert.
  3. App icon is managed by SKStoreReviewController, and fetched from your app detail on iOS app store.
  4. SKStoreReviewController is available in iOS 10.3 and above.

Steps to show app rating alert in iOS using SKStoreReviewController

Step 1: Import StoreKit framework

Step 2: Open your swift class, where you want to implement this app rating alert. Create a function to request review pop up usingSKStoreReviewController class. Below is the code for asking app rating pop up.

import UIKit
import StoreKit

class ViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view.
       	self.requestAppReview()
    }
    
    func requestAppReview() {
        if #available(iOS 14.0, *) {
            if let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene {
                SKStoreReviewController.requestReview(in: scene)
            }
        } else {
            SKStoreReviewController.requestReview()
        }
    }
}

Since requestReview is deprecated in IOS 14.0 and onward. So we will use, requestReview(in: scene) function introduced after iOS 14.0 and onward. That’s it and we have implemented app rating pop up in our iOS app. You will see a pop up in your app like this (please ignore the app icon as it’s taken from app that is already on iOS app store).