In-app reviews for your Android apps

Saamer Mansoor

Saamer

This is a guest blog by Saamer Mansoor. Saamer is a tinkerer and an app developer at TheFirstPrototype.com. You can find him on Twitter @saamerm, writing on Medium, and contributing to Open Source on GitHub.

When Android’s Play Core v1.8 was released in August 2020, it added an awesome new feature to enable users to provide in-app reviews. Patrick Getzmann has been working on a binding for this library for the past few months and he recently updated it to support v1.8. This means that with just a few lines of code you can bring this feature and many others to your app.

In-app reviews improve the user experience as users dislike being taken outside their app. Apple has provided this feature since iOS 10.3 released in March 2017, so it was highly anticipated on Android. Let’s see how we can use the new Play Core library to bring this feature to Android apps.

Screenshots showing In-App Reviews on a Xamarin Android app

Play Core Library

At the start of this journey I worked closely with Patrick to update the PlayCore NuGet package that can be directly added to your Android project. Since the API is core to Android I made this PR to Patrick’s project as an example of how to use it. It shows how to create an InAppReviewService.cs in your Android project and use dependency injection to call it.

However, out of nowhere James Montemagno reached to me about integrating this functionality into his already popular Store Review Plugin. We partnered with him to make the feature more accessible through his NuGet library which already had the feature for iOS. This means that implementing this in your app is now simple!

Step 1 – Add the NuGet

The first step is to add the newly updated v3 of the Store Review Plugin NuGet to all of your projects. This will automatically add the Play Core bindings library as a dependency.

Step 2 – Call RequestReview()

Next, decide on how you want to request the review. You could trigger it when the user clicks a button, or you could manually trigger it after the user has used the app for a specific amount of time. When you want to request a review simply call this following line of code:

await CrossStoreReview.Current.RequestReview(false);

This will trigger the review process and the operating system will decide if it is presented. The boolean passed in is to determine if you are in test mode, which is great for testing your app before releasing.

Step 3 – Optional ProGuard Config

If you are releasing your app with the Link All option and have ProGuard/r8 enabled, you have to add the following in the proguard file in your Android project:

-keep class com.google.android.play.core.common.PlayCoreDialogWrapperActivity
-keep class com.google.android.play.core.review.** { *; }
-keep class com.google.android.play.core.tasks.** { *; }

Testing

Testing in-app reviews is tricky on Android, just as it is on iOS. There are many limitations to being able to test your app as you can see here. Regardless of what you try, you won’t be able to see the In-App review UI when built and distributed manually. You have to download the app from the Play Store, in order to see the UI. So, the easiest way to test this is by using Android’s “Internal App Sharing”.

And there you have it, you now have cross-platform in-app reviews for your Xamarin apps. Before, I end the post I wanted to give everyone a bit of a back story of how the entire library and integration came to be and I hope that sharing my story will encourage you to contribute to the awesome Xamarin community.

Back Story

It all started with Reddit actually. I subscribe to the Android subreddit through which I learn about the latest features. When I heard about the in-app reviews on Android, I was curious to implement it in my app too, but then I researched and learned that there weren’t any plans to have an official binding for Play Core. However, I found Patrick Getzman‘s NuGet that already had done the heavy lifting of creating a binding. At the time it only was bound against Play Core v1.7.2. Since v1.8 is needed for in-app reviews, so I simply created an issue.

A bit time later, I had a deadline creeping, so I decided to procrastinate and find anything to do instead, and that’s when I decided to update that bindings library to v1.8. With many mouse scrolls and key taps, I followed this video by Jonathan Dick and got the .AAR file for v1.8 from Android working after some trial and error! I submitted a PR and was able to use the Official Android documentation to update the example in Pat’s repository. It was a wonderful experience and glad I was able to help contribute this excellent feature.

I hope that you have found this handy, and if you use this in your apps, please share screenshots with me, or you can just say Hi!

15 comments

Leave a comment