Freelancing for Pale Blue

Looking for flexible work opportunities that fit your schedule?


"Rate this app" functionality using In-App Review API

Android Aug 22, 2020

Requesting a Play Store user review for your Android app is one of the most effective ways of getting more reviews/ratings. Until now this was usually implemented by informing the user about your desire to receive a review and then launching Play Store to your app's listing page.

This was not the best experience. A user leaving your app is (almost) never your intention. The experience of leaving your app, launching another app, and then return is not ideal. Also, the possibility that the user might get distracted in Play Store and forget to return to your app was quite real.

Fortunately, now there's an API that allows you to show discrete in-app pop-ups to urge users to rate (or review). The user will not have to leave your app.  This is available for Android 5.0 (API level 21) devices or above with Play Store installed (obviously).

When to show the popup

There are some (quite reasonable in my opinion) guidelines on when you should show the pop-up. In short:

  • the user must have spent some "reasonable" time in the app to form an opinion
  • not to spam the user with review requests
  • not influencing the user in any way before or during the review process (e.g. asking whether they enjoy the app before asking for a review)

Check out the official doc since this is a sensitive guideline that needs to be respected.

Set up

Slightly modify your build.gradle to include the Play Core library:

dependencies {
    implementation 'com.google.android.play:core:1.8.0'
    implementation 'com.google.android.play:core-ktx:1.8.1'
}
build.gradle (app)

Check out the official doc for the latest versions.

Usage

It's super easy to make the review request pop-up to appear. There are just a few points that you need to know.

val manager = ReviewManagerFactory.create(context) // [1]
val request = manager.requestReviewFlow()
request.addOnCompleteListener { request ->
    if (request.isSuccessful) {
        val reviewInfo = request.result // [2]
        val flow = manager.launchReviewFlow(activity, reviewInfo) [3]
        flow.addOnCompleteListener { _ ->
            // [4]
        }
    } else {
        // [5]
    }
}
  1. ReviewManager is the main interface for interacting with the in-app review flow.
  2. You need a ReviewInfo to show the pop-up. Note here that this object is valid for a limited time. So you should not get this way before you intend to show the pop-up because it might expire.
  3. This is what shows the pop up. Note that this does not guarantee that the pop-up will be shown. If the requirements are met (e.g. the user has not already reviewed the app) and there is a quota, then the dialog will be shown.
  4. When this point is reached it means that the review request process has finished. You can resume your app functionality. It does not mean that the dialog was shown or the user reviewed the app. Just that the review request flow is finished (e.g. the user might have chosen not to review the app).
  5. In case there's an issue when asking for a review request, resume the app functionality. No need to show an error message since this action is "optional" anyway.

Testing

To manually test the flow you would need to use a Play Console test track (and not have reviewed the app already). Additionally, for unit/integration tests a fake implementation is provided.

Hopefully, I've explained clearly and concisely about the new in-app review API. Happy review requests! :)

Tags

Great! You've successfully subscribed.
Great! Next, complete checkout for full access.
Welcome back! You've successfully signed in.
Success! Your account is fully activated, you now have access to all content.