fbpx
How to integrate In-App Reviews in Android using Kotlin

How to integrate In-App Reviews in Android using Kotlin

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 start, you need to know some things about when and where you have to ask users to rate your app.

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.8.0'
    implementation 'com.google.android.play:core-ktx:1.8.1'

    // ...

}

Integrating

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

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.
        }
    }
}

Testing

There are three ways to test your integration:

  • Internal test track: You need you have 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 do 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 you can’t see the In-App Review UI, but only the results in the console.

To test the demo app of this tutorial, just change the package name to the name of your app you have already 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 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 your 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 to the Internal track (Beta) in your device

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

Create a release for your app in the Internal testing

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

Press Start rollout to Internal testing

Go to your device and 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 in 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 Settings, tap 5-6 times the Play Store version to enable developer’s options.

After this, on the same screen, you’ll see the Internal app sharing option, 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 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
7 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
AD_LB

Seems like the in-app-review has a terrible & shady UX.
All of a sudden without requesting anything, shows a review to be filled.
Add to it the fact that it’s completely unreliable as you can’t know if it’s going to show up or not, and it’s really useless.

AD_LB

It could be great if it tried to use the one here when the user agrees to put a review.
Sadly the SDK doesn’t quite allow this.
I do wonder what would happen if I find a workaround for this though, if it’s allowed.

Hitesh

Fantastic explanation and tutorial… Thank you for sharing.

Fran Pulido

Hi, thanks for the great tutorial but I miss one thing that is.. how to handle when the user has added the rating and the comment, is there any method to know this?
Because I see when the user add a comment and click again nothing happen.