How to implement in-game review popup?

Hi, I’m trying to implement in-game review pop up without leaving the game. using google play services.

I installed:
→ com.google.play.core-1.8.1.unitypackage
→ com.google.play.review-1.8.1.unitypackage

But whenI’m creating the reviewManger

using System.Collections;
using UnityEngine;
using Google.Play.Review;

public class ReviewManager : MonoBehaviour
{
    private ReviewManager _reviewManager;
    private PlayReviewInfo _playReviewInfo;

    public void RequestReviewFlow()
    {
        _reviewManager = new ReviewManager();
        var requestFlowOperation = _reviewManager.RequestReviewFlow();
        requestFlowOperation.Completed += OnRequestFlowComplete;
    }

    private void OnRequestFlowComplete(OperationResult<ReviewInfo> result)
    {
        if (result.Error != ReviewErrorCode.NoError)
        {
            // Error handling
            return;
        }
        _playReviewInfo = result.GetResult().PlayReviewInfo;
        LaunchReviewFlow();
    }

    public void LaunchReviewFlow()
    {
        if (_playReviewInfo == null)
        {
            // Error handling
            return;
        }
        var launchFlowOperation = _reviewManager.LaunchReviewFlow(_playReviewInfo);
        launchFlowOperation.Completed += OnLaunchFlowComplete;
    }

    private void OnLaunchFlowComplete(OperationResult result)
    {
        // Review flow finished, no indication of whether the user reviewed or not.
    }
}

I got only red lines for missing references…

It will be nice to see a tutorial to show how to implement it, an example of it.
There is no examples :frowning:

I already fixed , and I want to post it for those who maybe have struggles like me :stuck_out_tongue:

using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using Google.Play.Review;

public class ReviewController : MonoBehaviour
{
    private ReviewManager _reviewManager;
    private PlayReviewInfo _playReviewInfo;

    void Start()
    {
        _reviewManager = new ReviewManager();
    }

    public void RequestReview()
    {
        StartCoroutine(RequestReviewCoroutine());
    }

    IEnumerator RequestReviewCoroutine()
    {
        var requestFlowOperation = _reviewManager.RequestReviewFlow();
        yield return requestFlowOperation;

        if (requestFlowOperation.Error != ReviewErrorCode.NoError)
        {
            Debug.Log($"Error requesting review: {requestFlowOperation.Error}");
            yield break;
        }

        _playReviewInfo = requestFlowOperation.GetResult();
        StartCoroutine(LaunchReviewCoroutine());
    }

    IEnumerator LaunchReviewCoroutine()
    {
        var launchFlowOperation = _reviewManager.LaunchReviewFlow(_playReviewInfo);
        yield return launchFlowOperation;

        _playReviewInfo = null;

        if (launchFlowOperation.Error != ReviewErrorCode.NoError)
        {
            Debug.Log($"Error launching review: {launchFlowOperation.Error}");
            yield break;
        }

        Debug.Log("Review launched successfully");
    }
}

I hope this will help other people! :smile:

2 Likes