playgameservices / play-games-plugin-for-unity

Google Play Games plugin for Unity
Other
3.45k stars 962 forks source link

Google play serices doesn't call authentificate function #3310

Open Bomjdeveloper opened 1 month ago

Bomjdeveloper commented 1 month ago

Describe the bug I have the following code: `

void Awake() {
        PlayGamesPlatform.Activate();
        PlayGamesPlatform.DebugLogEnabled = true;
    }
    void Start()
    {

        PlayGamesPlatform.Instance.Authenticate(ProcessAuthentication);
    }

    private void ProcessAuthentication(SignInStatus status) {
        if(status == SignInStatus.Success) {
            Debug.Log("Success");
            txt.text = "Success";
        }
        else {
            Debug.Log("Failure");
            txt.text = "Failure";
        }

    }`

in editor the text says failure, but after build in android it doesn't even say failure. Google play services are set up correct. I don't use any minyfication or others sings

To Reproduce Steps to reproduce the behavior:

  1. try to use sign in func

Expected behavior Just to login or report failure

Observed behavior It doesn't even call the authentificate function

Versions

Additional context Add any other context about the problem here.

wigg commented 1 month ago

This is my code I using in Versions

using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using UnityEngine.SocialPlatforms; using GooglePlayGames; using GooglePlayGames.BasicApi;

public class playGamesManager : MonoBehaviour { public Text DetailsText;

public bool connectedToGooglePlay;

private void Awake()
{
    PlayGamesPlatform.DebugLogEnabled = true;
    PlayGamesPlatform.Activate();
}

void Start()
{
    LogInToGooglePlay();
}

public void LogInToGooglePlay()
{
    PlayGamesPlatform.Instance.Authenticate(ProcessAuthentication);
}

internal void ProcessAuthentication(SignInStatus status)
{
    if (status == SignInStatus.Success)
    {
        connectedToGooglePlay = true;

        string name = PlayGamesPlatform.Instance.GetUserDisplayName();
        string id = PlayGamesPlatform.Instance.GetUserId();
        string ImgUrl = PlayGamesPlatform.Instance.GetUserImageUrl();

    }
    else
    {
        DetailsText.text = "Sign in Failed!!";
        connectedToGooglePlay = false;
    }
}

public void ShowLeaderboardUI()
{
    if (!connectedToGooglePlay)
    {
        LogInToGooglePlay();
    }
    else
    {
        PlayGamesPlatform.Instance.ShowLeaderboardUI("XXXXXX-XXXXXX");
    }
}

public void PostToLeaderboard()
{
    // Check if connected to Google Play Services
    if (connectedToGooglePlay)
    {
        // Assuming your Score returns a System.Numerics.BigInteger
        System.Numerics.BigInteger scoreValue = 1; //change 1 to the score you want to use

        // Convert BigInteger to long
        long longScoreValue = (long)scoreValue;

        // Report the score to the leaderboard
         PlayGamesPlatform.Instance.ReportScore(longScoreValue, "XXXXXX-XXXXXX", (bool success) => {
            if (success)
            {
                Debug.Log("Posted new score to leaderboard");
            }
            else
            {
                Debug.LogError("Unable to post new score to leaderboard");
            }
        });

        // Update the DetailsText to show the score
        DetailsText.text = scoreValue.ToString();
    }
    else
    {
        // Handle the case when not connected to Google Play Services
        Debug.LogWarning("Not connected to Google Play Services. Highscore unable to post");
    }
}

public void LeaderboardUpdate(bool success)
{
    if(success)
    {
        Debug.Log("Updated Leaderboard");
    }
    else
    {
        Debug.Log("Unable To Updated Leaderboard");
    }
}

}