Prompt users to rate your app in iOS with StoreKit.

By | November 13, 2018

Apple has introduced a new API to allow developers to prompt users with rate their apps directly from the app.

Old way

In the old way, we used to redirect users to the Appstore with the app’s link to rate the app.
This makes users to navigate out of the app. This was not an efficient way to do it.

Sample code will look like this in swift


func rateApp(appId: String) {
   openUrl(“itms-apps://itunes.apple.com/app/” + appId)
}

func openUrl(_ urlString:String) {
  let url = URL(string: urlString)!
  if #available(iOS 10.0, *) {
    UIApplication.shared.open(url, options: [:], completionHandler: nil)
  } else {
    UIApplication.shared.openURL(url)
  }
}

New Way

Objective C

#import <StoreKit/StoreKit.h>

+(void) displayReviewController {
    if (@available(iOS 10.3, *)) {
        [SKStoreReviewController requestReview];
    }
}

In Swift

func requestReview() {
   if #available(iOS 10.3, *) {
       SKStoreReviewController.requestReview()
   } else {
      // Fallback on earlier versions
      // Try any other 3rd party or manual method here.
  }
}

When to Show?

1. Ask for a rating only after the user has demonstrated engagement with your app.
2. Don’t interrupt the user, especially when they’re performing a time-sensitive or stressful task

Note

1. The OS will prevent more than 3 times in 365 times.
2. When the app is in development, the review will show up, but you won’t be able to review the app.
3. The app in the TestFlight has the same behaviour as the app in the Development.

Leave a Reply

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