Integrar avaliações no app (Unity)
Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
Este guia descreve como integrar avaliações no app usando o Unity.
Há guias de integração separados para casos em que você está usando Kotlin ou Java,
código nativo ou o Unreal Engine.
Visão geral do SDK do Unity
A API Play In-App Review faz parte da família do SDK da Play Core. A API para
Unity oferece uma classe ReviewManager
para solicitar e iniciar o fluxo usando
os métodos RequestReviewFlow
e LaunchReviewFlow
. Depois que uma
solicitação é feita, o app pode verificar o status dela usando
ReviewErrorCode
.
Configurar seu ambiente de desenvolvimento
OpenUPM-CLI
Se você tiver a CLI do OpenUPM
instalada, poderá instalar o registro do OpenUPM com o seguinte comando:
openupm add com.google.play.review
OpenUPM
Abra as configurações do gerenciador de pacotes
selecionando a opção de menu do Unity
Edit > Project Settings > Package Manager.
Adicione o OpenUPM como um registro de escopo à janela do Gerenciador de pacotes:
Name: package.openupm.com
URL: https://package.openupm.com
Scopes: com.google.external-dependency-manager
com.google.play.common
com.google.play.core
com.google.play.review
Abra o menu do gerenciador de pacotes selecionando a opção de menu
do Unity Window > Package Manager.
Defina o menu suspenso "Escopo do administrador" para selecionar Meus registros.
Selecione o pacote Google Play Integrity plugin for Unity na
lista de pacotes e pressione Install.
Importar do GitHub
Faça o download da versão mais recente do .unitypackage
no GitHub.
Importe o arquivo .unitypackage
selecionando a opção de menu
Assets > Import package > Custom Package do Unity e importando todos os itens.
Criar o ReviewManager
Crie uma instância de ReviewManager
que processe a comunicação entre
seu app e a API Google Play.
using Google.Play.Review;
// Create instance of ReviewManager
private ReviewManager _reviewManager;
// ...
_reviewManager = new ReviewManager();
Solicitar um objeto ReviewInfo
Siga as orientações sobre quando solicitar avaliações no app para determinar bons
pontos no fluxo do usuário para solicitar uma avaliação (por exemplo,
depois que um usuário dispensar a tela de resumo ao final de um nível em um jogo). Quando
o app estiver perto de um desses pontos, use a instância ReviewManager
para criar uma operação assíncrona, como mostrado no exemplo a seguir:
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();
Se a chamada for bem-sucedida, a API vai retornar o objeto PlayReviewInfo
necessário para iniciar o fluxo de avaliação no app. No exemplo, a chamada
é feita dentro de uma corrotina
para executar a operação assíncrona. Isso não bloqueia a linha de execução principal. Como
a chamada é feita de maneira assíncrona, ela pode demorar alguns segundos. Assim,
o app precisa fazer a chamada antes de chegar ao ponto no fluxo
de usuários em que você quer exibir a chamada de avaliação no app.
Iniciar o fluxo de avaliação no app
Depois que o app receber a instância PlayReviewInfo
, ele poderá iniciar o
fluxo de avaliação. O objeto PlayReviewInfo
é válido apenas por um
período limitado. Portanto, seu app não pode esperar muito tempo antes de iniciar um
fluxo.
var launchFlowOperation = _reviewManager.LaunchReviewFlow(_playReviewInfo);
yield return launchFlowOperation;
_playReviewInfo = null; // Reset the object
if (launchFlowOperation.Error != ReviewErrorCode.NoError)
{
// Log error. For example, using launchFlowOperation.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.
Próximas etapas
Teste o fluxo de avaliações no app para verificar se a integração está
funcionando corretamente.
O conteúdo e os exemplos de código nesta página estão sujeitos às licenças descritas na Licença de conteúdo. Java e OpenJDK são marcas registradas da Oracle e/ou suas afiliadas.
Última atualização 2025-07-27 UTC.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Não contém as informações de que eu preciso","missingTheInformationINeed","thumb-down"],["Muito complicado / etapas demais","tooComplicatedTooManySteps","thumb-down"],["Desatualizado","outOfDate","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Problema com as amostras / o código","samplesCodeIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-07-27 UTC."],[],[],null,["# Integrate in-app reviews (Unity)\n\nThis guide describes how to integrate in-app reviews in your app using Unity.\nThere are separate integration guides for if you are using [Kotlin or Java](/guide/playcore/in-app-review/kotlin-java),\n[native code](/guide/playcore/in-app-review/native) or [Unreal Engine](/guide/playcore/in-app-review/unreal-engine).\n\nUnity SDK overview\n------------------\n\nThe Play In-App Review API is part of [Play Core SDK](/reference/com/google/android/play/core/release-notes) family. The API for\nUnity offers a [`ReviewManager`](/reference/unity/class/Google/Play/Review/ReviewManager) class to request and launch the flow using\nthe [`RequestReviewFlow`](/reference/unity/class/Google/Play/Review/ReviewManager#requestreviewflow) and [`LaunchReviewFlow`](/reference/unity/class/Google/Play/Review/ReviewManager#launchreviewflow) methods. After a\nrequest is made, your app can check the status of the request using\n[`ReviewErrorCode`](/reference/unity/namespace/Google/Play/Review#reviewerrorcode).\n\nSet up your development environment\n-----------------------------------\n\n### OpenUPM-CLI\n\nIf you have the [OpenUPM CLI](https://github.com/openupm/openupm-cli#installation)\ninstalled you can install the OpenUPM registry with the following command: \n\n openupm add com.google.play.review\n\n### OpenUPM\n\n1. Open the [package manager settings](https://docs.unity3d.com/Manual/class-PackageManager.html)\n by selecting the Unity menu option\n **Edit \\\u003e Project Settings \\\u003e Package Manager**.\n\n2. Add OpenUPM as a scoped registry to the Package Manager window:\n\n Name: package.openupm.com\n URL: https://package.openupm.com\n Scopes: com.google.external-dependency-manager\n com.google.play.common\n com.google.play.core\n com.google.play.review\n\n3. Open the [package manager menu](//docs.unity3d.com/Manual/upm-ui-install.html) by selecting the Unity\n menu option **Window \\\u003e Package Manager**.\n\n4. Set the manager scope drop-down to select **My Registries**.\n\n5. Select the **Google Play Integrity plugin for Unity** package from the\n package list and press **Install**.\n\n### Import from GitHub\n\n1. Download the latest [`.unitypackage`](//github.com/google/play-in-app-reviews-unity/releases/latest)\n release from GitHub.\n\n2. Import the `.unitypackage` file by selecting the Unity menu option\n **Assets \\\u003e Import package \\\u003e Custom Package** and importing all items.\n\n| **Note:** By downloading and using Google Play Unity Plugins, you agree to the [Play Core Software Development Kit Terms of Service](/guide/playcore#license).\n\nCreate the ReviewManager\n------------------------\n\nCreate an instance of [`ReviewManager`](/reference/unity/class/Google/Play/Review/ReviewManager) that handles communication between\nyour app and the Google Play API. \n\n using Google.Play.Review;\n\n // Create instance of ReviewManager\n private ReviewManager _reviewManager;\n // ...\n _reviewManager = new ReviewManager();\n\nRequest a ReviewInfo object\n---------------------------\n\nFollow the guidance about [when to request in-app reviews](/guide/playcore/in-app-review#when-to-request) to determine good\npoints in your app's user flow to prompt the user for a review (for example,\nafter a user dismisses the summary screen at the end of a level in a game). When\nyour app gets close one of these points, use the [`ReviewManager`](/reference/unity/class/Google/Play/Review/ReviewManager) instance\nto create an async operation, as shown in the following example: \n\n var requestFlowOperation = _reviewManager.RequestReviewFlow();\n yield return requestFlowOperation;\n if (requestFlowOperation.Error != ReviewErrorCode.NoError)\n {\n // Log error. For example, using requestFlowOperation.Error.ToString().\n yield break;\n }\n _playReviewInfo = requestFlowOperation.GetResult();\n\nIf the call is successful, the API returns the [`PlayReviewInfo`](/reference/unity/class/Google/Play/Review/PlayReviewInfo) object\nthat your app needs to launch the in-app review flow. In the example, the call\nis made inside a [coroutine](https://docs.unity3d.com/Manual/Coroutines.html)\nto perform the async operation (this does not block the Main thread). Because\nthe call is made asynchronously, it might take up to a couple of seconds, so\nyour app should make the call before your app reaches the point in your user\nflow where you want to show the in-app review.\n\nLaunch the in-app review flow\n-----------------------------\n\nAfter your app receives the [`PlayReviewInfo`](/reference/unity/class/Google/Play/Review/PlayReviewInfo) instance, it can launch the\nin-app review flow. Note that the `PlayReviewInfo` object is only valid for a\nlimited amount of time, so your app should not wait too long before launching a\nflow. \n\n var launchFlowOperation = _reviewManager.LaunchReviewFlow(_playReviewInfo);\n yield return launchFlowOperation;\n _playReviewInfo = null; // Reset the object\n if (launchFlowOperation.Error != ReviewErrorCode.NoError)\n {\n // Log error. For example, using launchFlowOperation.Error.ToString().\n yield break;\n }\n // The flow has finished. The API does not indicate whether the user\n // reviewed or not, or even whether the review dialog was shown. Thus, no\n // matter the result, we continue our app flow.\n\nNext steps\n----------\n\n[Test your app's in-app review flow](/guide/playcore/in-app-review/test) to verify that your integration is\nworking correctly."]]