Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google play serices doesn't call authentificate function #3310

Open
Bomjdeveloper opened this issue Jul 28, 2024 · 1 comment
Open

Google play serices doesn't call authentificate function #3310

Bomjdeveloper opened this issue Jul 28, 2024 · 1 comment
Labels

Comments

@Bomjdeveloper
Copy link

Bomjdeveloper commented Jul 28, 2024

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

  • Unity version: unity 6
  • Google Play Games Plugin for Unity version: 0.11.01

Additional context
Add any other context about the problem here.

@wigg
Copy link

wigg commented Jul 31, 2024

This is my code I using in
Versions

  • Unity version: unity 6
  • Google Play Games Plugin for Unity version: 0.11.01

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");
    }
}

}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants