This guide describes how to integrate in-app reviews in your app using Unity. There are separate integration guides for if you are using Kotlin or Java or native code.
Unity SDK overview
The Play In-App Review API is part of Play Core
SDK family. The API for
Unity offers a ReviewManager
class to request and launch the flow using the RequestReviewFlow
and LaunchReviewFlow
methods. After a request is made, your app can check the status of the request
using ReviewErrorCode
.
Set up your development environment
Download the latest release of Play In-App Review Unity Plugin from Google packages for Unity.
Create the ReviewManager
Create an instance of ReviewManager
that handles communication between your app and the API.
// Create instance of ReviewManager
private ReviewManager _reviewManager;
// ...
_reviewManager = new ReviewManager();
Request a ReviewInfo object
Follow the guidance about when to request in-app
reviews to determine good points
in your app's user flow to prompt the user for a review (for example, after a
user dismisses the summary screen at the end of a level in a game). When your
app gets close one of these points, use the ReviewManager
instance to create an async operation, as shown in the following example:
var requestFlowOperation = _reviewManager.RequestReviewFlow();
yield return requestFlowOperation;
if (requestFlowOperation.Error != ReviewErrorCode.NoError)
{
// Log error. For example, using requestFlowOperation.Error.ToString().
yield break;
}
_playReviewInfo = requestFlowOperation.GetResult();
If the call is successful, the API returns the PlayReviewInfo
object that your app needs to launch the in-app review flow. In the example, the
call is made inside a coroutine
to perform the async operation (this does not block the Main thread). Because
the call is made asynchronously, it might take up to a couple of seconds, so
your app should make the call before your app reaches the point in your user
flow where you want to show the in-app review.
Launch the in-app review flow
After your app receives the PlayReviewInfo
instance, it can launch the in-app review flow. Note that the PlayReviewInfo
object is only valid for a limited amount of time, so your app should not wait
too long before launching a flow.
var launchFlowOperation = _reviewManager.LaunchReviewFlow(_playReviewInfo);
yield return launchFlowOperation;
_playReviewInfo = null; // Reset the object
if (launchFlowOperation.Error != ReviewErrorCode.NoError)
{
// Log error. For example, using requestFlowOperation.Error.ToString().
yield break;
}
// 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.
Next steps
Test your app's in-app review flow to verify that your integration is working correctly.