Implement In-App Reviews to get more Reviews

App reviews and ratings are essential part in growth of an android app, and making a user to review or rate your app was never easy. Now, we have In-App Reviews which shows a dialog flow at the bottom of the app to allow user to rate and review your app right inside your app.

ReviewFlow

In this article, we’ll implement this feature and you can follow along to add it to your app right now.

Adding the dependency

To perform In-App reviews you’ll need to add Play Core Dependency to your app. This library also includes In-app Updates, and many others. For now we’ll only use In-App reviews which requires the core library version over 1.8.0 (<1.8.0).

implementation 'com.google.android.play\:core\:1.8.0'

Just simply add the above dependency to your app level build.gradle file and you’re good to go.

Limitations Of In-App Reviews

At the time of writing this,

  • You can’t change the design and looks of review flow
  • You can’t show any other overlay over the review flow

However, the default material style flow looks pretty decent. Read more about practices to be followed

Implementation

Enough talk, let’s start implementing the thing 👷🏻‍♂️.

There are three key points for this implementation :

1. Point where you need to show the rating flow ?

Generally, it is advisable to show a review flow when user will probably complete something great in your app as this might lead to a chance of a positive review. For example, if you offer a food ordering service a rating flow dialog when user successfully places an order would lead to a postive review(Probably).

Once you choose the point where you want to show the rating flow :

We create a ReviewManager Object

// creates a ReviewManager object with a name manager
ReviewManager manager = ReviewManagerFactory.create(context)
  
 // creates a task which gets the information about the app from google play
Task<ReviewInfo> request = manager.requestReviewFlow();
request.addOnCompleteListener(task -> {
    if (task.isSuccessful()) {
      	ReviewInfo reviewInfo = task.getResult();
      	// we then send the info to another function which handles the rest
      	handleReviewInfo(reviewInfo)
    } else {
        // There was some problem, log or handle the error code.
        @ReviewErrorCode int reviewErrorCode = ((TaskException) task.getException()).getErrorCode();
    }
});

For Kotlin People :

val reviewManager = ReviewManagerFactory.create(context)

internal val request: LiveData<ReviewInfo> get() = appRating
private val appRating = SingleLiveEvent<ReviewInfo>()
appRating.value = reviewManager.requestReview()

This above function will basically get the information from the google play which are required to launch the review flow. Let me assume everything was right and we got the review info. As we got all the information and are ready to launch the review flow.

2. Show the Review Flow Dialog

We’ll use the reviewInfo instance from the previous step to launch the review dialog and let the user rate and review our app.

Just call this function to launch the flow :

private void handleReviewInfo(ReviewInfo reviewInfo) {
  Task<Void> flow = manager.launchReviewFlow(activity, reviewInfo);
}

Kotlin people :

fun handleReviewInfo() reviewInfo: ReviewInfo {
  reviewManager.launchReviewFlow(requireActivity(), reviewInfo)
}

The above function will basically launch the dialog with the information retrieved and allows the user to rate and write feedback.

Note : You’ll not know the information about what user rated or written in the feedback form.

You can offcourse know when user cancelled or completed the review flow with a listener to the task :

flow.addOnCompleteListener(task -> {
   // when completed or cancelled this will be executed 
});

3. Testing if everything works

You always have to test the implementation before rolling-out to production. This way you can find bugs and issues with your implementation.

Internal Test Track

This method is not that straightforward, but there are no restrictions on sending feedback to test your app thoroughly

You can do it in 5 simple steps:

  • Add your app to the internal track in Google play console.
  • Ensure that your gmail account logged into play store is in the list of testers.

  • Download your app from the internal track.

  • Delete your existing review, if you reviewed already. This might take a little time to change.

  • Acheive the condition you set to show a review flow.

If you want to cover this feature in unit-tests, then there is also handy FakeReviewManager, which will help you fake the API’s behavior (it doesn’t simulate the UI).

That’s it, This is how you implement and test In-App Review flow in your app. If you face any kind of issue with in integration, use the comment section and I’ll be happy to help.