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?’
Contents
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.
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 the 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 for the Internal track (Beta) on your device
After that, choose the Releases tab and upload your app.
After you upload it, 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.
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 on your device
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.
Now, open the URL you copied before, download it, and run the app!
You can find the final project here
If you have any questions, please feel free to leave a comment below