How to implement the Google Play In-App Review API for Android

Matthew Callery
4 min readApr 21, 2023

Google Play’s In-App Review API allows you to request ratings/reviews from users without them having to leave your app. Those reviews will be submitted directly to your app’s Play Store listing.

The in-app review flow can be triggered at any time in your app’s user journey. During that flow, the user can rate your app 1–5 stars and leave an optional comment (review).

Google have strict guidelines that your app must follow to prevent abuse of this API, which you can read about in the Guidelines section below.

In-app review flow (credit to developer.android.com)

Implementation

Step 1: Add the dependency to your build.gradle (:app) file.

If you already have the Play Core dependency, make sure it’s v1.8.0 or above. This contains the In-App Review Library.

dependencies {
// This dependency is downloaded from Google's Maven repository.
// Make sure you also include that repository in your project's build.gradle file.
implementation 'com.google.android.play:core:1.10.3'
}

Otherwise, you can just add the In-App Review Library by itself.

dependencies {
// This dependency is downloaded from Google’s Maven repository.
// Make sure you also include that repository in your project's build.gradle file.
implementation 'com.google.android.play:review:2.0.1'
}

Step 2: Add this Activity extension function

fun Activity.launchInAppReview(
onComplete: (() -> Unit)? = null,
) {
val reviewManager = ReviewManagerFactory.create(this)
val request = reviewManager.requestReviewFlow()
request.addOnCompleteListener { task ->
if (task.isSuccessful) {
val reviewInfo = task.result
val flow = reviewManager.launchReviewFlow(this, reviewInfo)
flow.addOnCompleteListener {
// The flow has finished. The API doesn't indicate whether the user
// reviewed or not, or even whether the review dialog was shown.
// Therefore, no matter the result, continue with your app's flow.
onComplete?.invoke()
}
} else {
// Log or handle error if you want to
onComplete?.invoke()
}
}
}

onComplete is an optional method that you can invoke once the in-app review flow is completed.

Step 3: Call launchInAppReview

Call the extension function at a suitable point in your user flow.

A good example would be when a user completes a level in your game. You can then launch the next level from the flow.addOnCompleteListener block.

Important note: It’s not guaranteed that the user will be shown the in-app review card. However, the flow.addOnCompleteListener block will be called regardless of whether the in-app review card is shown.

Guidelines for In-App Review usage

When to request an in-app review

  1. Once the user has spent enough time on your app to provide useful feedback
  2. You should not ask the user any leading questions before making a request to the In-App Review API e.g. “Do you enjoy using this app?”
  3. Do not use a call-to-action (e.g. a button) to make a request to the In-App Review API. It’s not guaranteed that the in-app review card will be displayed, and your button will look broken.

Violating point 2 could lead to your app being removed from the Play Store.

Regarding point 3, if you want to add a button that asks the user to rate your app, that button should send the user to your Play Store listing instead of calling the In-App Review API.

Google’s design guidelines

  1. Do not attempt to alter the design of the in-app review card (e.g. by changing its size, shape, or colour scheme)
  2. Don’t try to show any view over the in-app review card, or next to it
  3. Once the in-app review card is displayed, don’t try to remove it programmatically

Quota for how often the in-app review card can be displayed

To stop the In-App Review API from being abused, Google Play enforce a time-based quota on how often you can show the in-app review card to a given user.

If you try to call launchInAppReview more than once in a short time period, Google probably won’t display the card more than once.

Google have not revealed what that time-based quota is, but a good estimate is that you can show a given user the in-app review card once per month.

Testing

If you’d like to test your In-App Review implementation, you can follow these instructions on the Android Developer site.

More info

If you want more information on the In-App Review API, for example terms of service or data safety, please check out the Android Developer documentation.

--

--

Matthew Callery

Senior Android Engineer at Tilt. Ex Epic Games. Indie hacking on CV Engineer (750k downloads). Android & iOS Engineer.