In App Rating Popup(Apple Rating Popup)

Neha Jain
4 min readMar 13, 2021

--

Hello Guys, So today I am going to explain In App Rating Popup.

Topics -

  1. What is In App Rating Popup?
  2. How it looks?
  3. Implementation
  4. Limitations
  5. Important Notes

What is In App Rating Popup?

Till Yet for rating we have only one option that is App Store Redirection. From iOS version 10.3, apple made it possible for developers to ask for rating inside the application. Through SKStoreReviewController API this is possible.

How it looks?

Implementation -

Step 1. import StoreKit

Step 2. As I mentioned earlier it started from version 10.3 so have to set a check for that –

if #available(iOS 14.0, *) {

if let scene = UIApplication.shared.connectedScenes.first as? UIWindowScene {

SKStoreReviewController.requestReview(in: scene)

} else {

SKStoreReviewController.requestReview()

}

Only above mentioned two steps are required to implement this.

LIMITATIONS -

So, when Apple was providing this feature they were worried equally for user comfort and experience. That is why Apple limit this for 3 times in a period of 365 Days.

Now there can be multiple cases regarding implementation –

Case 1. Suppose you have a User Experience Popup in which after completion of a task you are asking from user that –

are you enjoying our application?

1. YES 2. NO

If user select Yes then you will call SKStoreReviewController.requestReview().

Case 2. Maybe you want to open it on your session basis according your business logics.

Case 3. Maybe you want to open it according your app Launch.

But As we all know now that it will happen only 3 times in a Year, then what about other time. So, in that case we can redirect application to App Store Rating, through below given code –

if let url = URL(string: “itms-apps://itunes.apple.com/app/” + “appId”) {

if #available(iOS 10, *) {

UIApplication.shared.open(url, options: [:], completionHandler: nil)

} else {

UIApplication.shared.openURL(url)

}

}

Now the Question is how you will Decide when you have to redirect your code on AppStore or SKStore.

1. Apple do not have any callback for this till now.

2. So, we can make it possible through multiple ways –

a. Window Count

b. Session Count / App Launch Count

c. On version basis

WINDOW COUNT –

Pros –

1. You have to write 2 line of code and everything is done.

2. Here is the code example –

Example -

func openAppRatingPopup() {

let windowCount = UIApplication.shared.windows.count

if #available (iOS 10.3, *) {

SKStoreReviewController.requestReview()

DispatchQueue.main.asyncAfter(deadline: .now() + 2) {

if windowCount == UIApplication.shared.windows.count

{

UIApplication.shared.open(url, options: [:], completionHandler: nil)

}

}

}

}

Cons –

1. If someday in some iOS version apple make any changes in window hierarchy or window functions it will affect your code.

2. When if user do something in same session you will not able to detect your popup is presented or not because your window count is similar which is after presenting your popup. So, both things will happen in your test mode because in test mode every time popup will present.

Session Count / App Launch –

Pros –

1. If you want to trigger In App Rating Popup according your app launch and session it will be the best way.

2. In this scenario you have to store somewhere your app launches maybe in your User Defaults or you can store a value on your server too. People usually do it through User Defaults.

3. Example –

import Foundationimport StoreKitclass  SpsRateManager {private static let instance = SpsRateManager()var shareinstance: SpsRateManager{return .instance}static func incrementAppOpenedCount() { // called from appdelegate didfinishLaunchingWithOptions:let userdefault = UserDefaults.standardlet savedvalue = userdefault.integer(forKey: Configuration.APPLICATIONOPENCOUNTSTATUS)if savedvalue == 0 {print("Not saved ")userdefault.set(1, forKey: Configuration.APPLICATIONOPENCOUNTSTATUS)}else{userdefault.set(savedvalue+1, forKey: Configuration.APPLICATIONOPENCOUNTSTATUS)}}static func checkAppopencountandProvideReview(){let userdefault = UserDefaults.standardlet appopencountvalue  = userdefault.integer(forKey:            Configuration.APPLICATIONOPENCOUNTSTATUS)if appopencountvalue % 10 == 0 {
print("its been 10 times so ask for review ")
SpsRateManager().requestReview()} else {
print("not enough open count don’t show ")
}
}
fileprivate func requestReview() {if #available(iOS 10.3, *) {SKStoreReviewController.requestReview()} else {// Fallback on earlier versions// Try any other 3rd party or manual method here.}}

Cons –

1. You have to use “User Defaults” for this. So basically one stored value will increase in your app.

ON VERSION BASIS –

Pros –

1. You can take care of your user’s experience so you can make it restrict on basis of your app versions.

2. Example — https://developer.apple.com/documentation/storekit/skstorereviewcontroller/requesting_app_store_reviews

3. You can use above mentioned link for code guidance.

Important Notes!!

Keep these points in mind while coding:

1. When you are in development, requesting a review will always show the review user interface, but you can’t submit an actual review.

2. When you are using TestFlight to test your app, requesting a review will do nothing at all. i.e., none of the requests will be approved, so do not panic if review dialog does not show up in your TestFlight sessions. Once the app goes to production, it would use the Apple’s methods to show the dialog whenever it is suitable.

3. Simply choose when to prompt users to rate your app, for up to three prompts in a 365-day period. Customers will submit a rating through the standardized prompt, and can authenticate with Touch ID to write and submit a review.

--

--

Neha Jain
Neha Jain

Written by Neha Jain

A keen iOS developer who always ready to explore and explain things 🧑‍💻 with full of enthusiasm with big dreams....

Responses (3)