Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

Resolved How to implement in-game review popup?

Discussion in 'Player Engagement' started by Spirit_Warrior, Mar 17, 2023.

  1. Spirit_Warrior

    Spirit_Warrior

    Joined:
    Jan 1, 2020
    Posts:
    16
    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

    Code (CSharp):
    1. using System.Collections;
    2. using UnityEngine;
    3. using Google.Play.Review;
    4.  
    5. public class ReviewManager : MonoBehaviour
    6. {
    7.     private ReviewManager _reviewManager;
    8.     private PlayReviewInfo _playReviewInfo;
    9.  
    10.     public void RequestReviewFlow()
    11.     {
    12.         _reviewManager = new ReviewManager();
    13.         var requestFlowOperation = _reviewManager.RequestReviewFlow();
    14.         requestFlowOperation.Completed += OnRequestFlowComplete;
    15.     }
    16.  
    17.     private void OnRequestFlowComplete(OperationResult<ReviewInfo> result)
    18.     {
    19.         if (result.Error != ReviewErrorCode.NoError)
    20.         {
    21.             // Error handling
    22.             return;
    23.         }
    24.         _playReviewInfo = result.GetResult().PlayReviewInfo;
    25.         LaunchReviewFlow();
    26.     }
    27.  
    28.     public void LaunchReviewFlow()
    29.     {
    30.         if (_playReviewInfo == null)
    31.         {
    32.             // Error handling
    33.             return;
    34.         }
    35.         var launchFlowOperation = _reviewManager.LaunchReviewFlow(_playReviewInfo);
    36.         launchFlowOperation.Completed += OnLaunchFlowComplete;
    37.     }
    38.  
    39.     private void OnLaunchFlowComplete(OperationResult result)
    40.     {
    41.         // Review flow finished, no indication of whether the user reviewed or not.
    42.     }
    43. }
    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 :(
     
  2. Spirit_Warrior

    Spirit_Warrior

    Joined:
    Jan 1, 2020
    Posts:
    16
    I already fixed , and I want to post it for those who maybe have struggles like me :p

    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.UI;
    3. using System.Collections;
    4. using Google.Play.Review;
    5.  
    6. public class ReviewController : MonoBehaviour
    7. {
    8.     private ReviewManager _reviewManager;
    9.     private PlayReviewInfo _playReviewInfo;
    10.  
    11.     void Start()
    12.     {
    13.         _reviewManager = new ReviewManager();
    14.     }
    15.  
    16.     public void RequestReview()
    17.     {
    18.         StartCoroutine(RequestReviewCoroutine());
    19.     }
    20.  
    21.     IEnumerator RequestReviewCoroutine()
    22.     {
    23.         var requestFlowOperation = _reviewManager.RequestReviewFlow();
    24.         yield return requestFlowOperation;
    25.  
    26.         if (requestFlowOperation.Error != ReviewErrorCode.NoError)
    27.         {
    28.             Debug.Log($"Error requesting review: {requestFlowOperation.Error}");
    29.             yield break;
    30.         }
    31.  
    32.         _playReviewInfo = requestFlowOperation.GetResult();
    33.         StartCoroutine(LaunchReviewCoroutine());
    34.     }
    35.  
    36.     IEnumerator LaunchReviewCoroutine()
    37.     {
    38.         var launchFlowOperation = _reviewManager.LaunchReviewFlow(_playReviewInfo);
    39.         yield return launchFlowOperation;
    40.  
    41.         _playReviewInfo = null;
    42.  
    43.         if (launchFlowOperation.Error != ReviewErrorCode.NoError)
    44.         {
    45.             Debug.Log($"Error launching review: {launchFlowOperation.Error}");
    46.             yield break;
    47.         }
    48.  
    49.         Debug.Log("Review launched successfully");
    50.     }
    51. }
    52.  
    I hope this will help other people! :D
     
    breban1 and SebT_Unity like this.