Integrating In-App Review API into Android App

Naveen T P
4 min readAug 6, 2020

As an Android developer, I always wanted to see how people would react to my apps. There are several ways a user could give feedback - through an email, over social media networks like Twitter, etc. But Play store rating and review is always been a crucial part of any app. It will not only help us getting the user feedback but on the other hand, it helps users to decide which app to choose from a similar category based on the ratings.

That being said, how would you encourage your users to give feedback on your app? You either provide a button asking Review somewhere in the NavigationDrawer/Toolbar or trigger the review popup after a user has experienced enough of your app. But when a user clicks on the button, we usually end up redirecting the user to the Play store app detail screen😑 We never wanted our customers to leave our application, but with this flow, we were forced to redirect the control to Play store app.

But Google finally heard us! They have introduced a new shiny API for in-app review functionality😎 With this API we can present a popup & ask for Review inside the app without having to redirect to Playstore. That’s Awesome, isn't it? Let’s learn all about it in this article.

Minimum requirements

  • Android devices should be running on Android 5.0 (API level 21) or higher and should have Google play store installed.
  • Chrome OS devices that have Google play store app installed.
  • Play core library with v1.8.0 or higher.

Design guidelines & Quota restrictions

  • The Review card (popup) should not be tampered or altered by modifying the design.
  • Any overlay should not be added on top or around the card.
  • Review dialog should not be programmatically removed (It will automatically be removed based on user actions)
  • To protect user privacy and avoid API misuse, this API has a limited quota per user. Hence this functionality should not be triggered on a button click.
  • Before presenting the Review card, the app should not ask user opinions like “Do you like the app?” or “Give this app 5 stars”, etc.

Let’s Implement!

  1. Add play-core library as a dependency in your build.gradle file.
implementation 'com.google.android.play:core:1.8.0'

2. Create a ReviewManager instance and request ReviewInfo object. The ReviewInfo object to be pre-cached before calling launchReviewFlow method. So, it should be fetched ahead of time.

private var reviewInfo: ReviewInfo? = nullval manager = ReviewManagerFactory.create(context)val request = manager.requestReviewFlow()
requestFlow.addOnCompleteListener { request ->
if (request.isSuccessful) {
//Received ReviewInfo object
reviewInfo = request.result
} else {
//Problem in receiving object
reviewInfo = null
}

3. Now, you can trigger launchReviewFlow to present the Review card to the user. It is suggested to show the review flow after the user has experienced enough of your app or game.

reviewInfo?.let {
val flow = reviewManager.launchReviewFlow(this@MainActivity, it)
flow.addOnCompleteListener {
//Irrespective of the result, the app flow should continue
}
}

That’s it! your app is all set✌️

Testing

While I was testing the app, I made a few mistakes. I’ll list it out here so that you won’t make the same mistakes that I did.

  1. We often test the new functionalities by creating a new project that would have new ApplicationId. In this case, while you test the app, make sure you give an ApplicationId that is already released and available in the play store.
  2. If you have given feedback in the past for your app, in-app review API’s launchReviewFlow will not present any Review card. It simply triggers a success event.
  3. Due to quota limitations, calling a launchReviewFlow method might not always display a dialog. It should not be linked with any button click event.
  4. To test one of my apps, I had to create a signed apk to see the Review card but for the other app, debug build worked just fine.
  5. To check other design guidelines and when to display a review card, refer to the official document here.

I have created a sample app to implement & test the functionality. You can refer to the source code for more understanding.

So, that’s everything for today. If you like the article don’t forget to hit the clap button(Did u know? You can clap up to 50?). Follow me here on Medium and share this article.

Buy me a coffee?
If you like this article, you can buy me a coffee. Thanks!

Happy coding folks!!

Let’s become friends on Twitter, Linkedin, Github.

--

--

Naveen T P

#AndroidDev | #iOSDev | Kotlin💙 | Swift💛 | Open source enthusiast | https://naveentp.github.io/