How to integrate In-App Reviews in Android using Kotlin

Last updated on: May 27, 2023

In this tutorial, I’ll show you how to ask users to rate your app inside your app using ‘In-App Reviews

We’re not going to use any 3rd party library but the official way that Google provides using their Google Play In-App Review API.

Before we begin, it’s important to note that in order to effectively ask users to rate your app, it’s crucial to understand the appropriate timing and placement within your app to make the request.

Google suggests that you have you ask your users when:

  • The user has experienced enough of your app or game.
  • The level has finished if it’s a game.
  • Don’t have a button to prompt the in-app review. The API itself knows when to show the review card.
  • Don’t ask anything before you ask for a review, such as ‘Do you like this app?’

Adding the library

Go to your app-level build.gradle file and add the following dependencies:

// ...

dependencies {

    // ...

    implementation 'com.google.android.play:core:1.10.3'
    implementation 'com.google.android.play:core-ktx:1.8.1'

    // ...

}Code language: Kotlin (kotlin)

Integrating

The integration is pretty easy. Call the method below when you want to ask your users to rate your app:

private fun inAppReview() {
    val reviewManager = ReviewManagerFactory.create(this)
    val requestReviewFlow = reviewManager.requestReviewFlow()
    requestReviewFlow.addOnCompleteListener { request ->
        if (request.isSuccessful) {
            // We got the ReviewInfo object
            val reviewInfo = request.result
            val flow = reviewManager.launchReviewFlow(this, reviewInfo)
            flow.addOnCompleteListener {
                // The flow has finished. The API does not indicate whether the user
                // reviewed or not, or even whether the review dialog was shown. Thus, no
                // matter the result, we continue our app flow.
            }
        } else {
            Log.d("Error: ", request.exception.toString())
            // There was some problem, continue regardless of the result.
        }
    }
}Code language: Kotlin (kotlin)

Testing

There are three ways to test your integration:

  • Internal test track: You need to have a published app in Google Play Store to be able to upload your .apk (or .aab) in the Internal test track
  • Internal app sharing: You upload your .apk (or .aab) without having your app in the Google Play Store, but you need a Google Play Developer Account.
  • FakeReviewManager: Instead of using the ReviewManager instance, you use the FakeReviewManager. This should be used only in unit or integration tests. The problem with this method is that you can’t see the In-App Review UI, only the console’s results.

To test the demo app of this tutorial, change the package name to the name of your app you already have on Google Play Store, and the versionCode.

If you don’t know how to change the package name, you can see here a step by step guide

Internal test track

After you build a signed .apk (or .aab), go to the Google Play Console, select your app, then Testing > Internal testing, choose the tab Testers, and press Create email list.

In the Google Play Console, in the Internal testing create a list of testers

On the new screen, give a name to your list, add your email, press Enter, and press Save Changes

Create email list to allow users to have access to Internal testing track

Back to the previous screen, select the list you created, add an email for feedback if you want, and press Save Changes.

Select your list with emails, add feedback email and press Save Changes in Internal testing track

Note: Don’t forget to press Copy the link. Through this link, you’ll be able to register for the Internal track (Beta) on your device

After that, choose the Releases tab and upload your app.

Create a release for your app in the Internal testing

After you upload it, press Start rollout to Internal testing.

Press Start rollout to Internal testing

Go to your device, open the link you copied before, register your account to the Internal track, download it, and run it!

Internal app sharing

After you build your .apk (or .aab), go to the Google Play Console, select your app, then Setup > Internal app testing, choose the tab Email list, select your email list, and press Save Changes.

Set your users that can download your app in Internal app sharing

Go back to the Uploaders and testers and open the link.

Open the link to share your app through Internal app sharing

Upload your .apk (or .aab)

Upload your .apk or .aab in Internal app sharing

After you upload your app, press the copy icon to get the URL and open it on your device

Copy the link from Internal app sharing

In your device, if you haven’t Internal app sharing enabled, open Google Play Store, go to Settings, and tap 5-6 times the Play Store version to enable developer’s options.

After this, you’ll see the Internal app sharing option on the same screen. Enable it, and press TURN ON.

Steps how to enable Internal app sharing in Google Play Store

Now, open the URL you copied before, download it, and run the app!

You can find the final project here

If you have any questionsplease feel free to leave a comment below

Subscribe
Notify of
guest
15 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments