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'
// ...
}
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:
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 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
On the new screen, give a name to your list, add your email, press Enter, and press Save Changes
Back to the previous screen, select your list you created, add an email for feedback if you want, and press Save Changes
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.
After you uploaded it, 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
Go back to the Uploaders and testers and open the link.
Upload your .apk (or .aab)
After you upload your app, press the copy icon to get the url, and open it in your device
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.
Now, open the url you copied before, download and run the app!
You can find the final project here
If you have any questions, please feel free to leave a comment below
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.
Yeah, it’s kinda weird.
You can check another implementation here.
I think this method is way better because you don’t even disrupt user’s experience
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.
Fantastic explanation and tutorial… Thank you for sharing.
Thank you!!
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.
No, you can’t know if they rated your app or not. As the comments in the code says:
How many times user allow to rate the app and from which account it will take the review and rating i mean it will take from google play account or from app account.
Google decides when it’s the best moment to ask the user for review.
The user will use their Google Play Account.
do we have control on UI
No, you can’t change it.
If you want full control, check this method