Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Social.localUser.Authenticate callback never called

I am trying to add Google Play Service into my Android app. When I call Social.localUser.Authenticate in Unity Editor, it return false to the callback function. But when my mobile runs the debugging build, the callback function is not been called. And no error message comes out.

enter image description here

And here is my code.

public void Init()
{
    // Initialize Play Games Configuration and Activate it.
    PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
    .EnableSavedGames()
    .RequestEmail()
    .RequestServerAuthCode(false)
    .RequestIdToken()
    .Build();

    PlayGamesPlatform.InitializeInstance(config);
    PlayGamesPlatform.DebugLogEnabled = true;
    PlayGamesPlatform.Activate();
    Debug.LogFormat("SignInOnClick: Play Games Configuration initialized");
}

public void SignInWithPlayGames()
{
    if (Social.localUser.authenticated) {
        return;
    }
    // Sign In and Get a server auth code.
    Debug.Log("Start Auth GPGS");
    Social.localUser.Authenticate((bool success) =>
    {
        Debug.Log("The lines below never call :("); // <<<<<<<<<<<<<<<<<<<<<<<<<<<
        if (!success) {
            Debug.LogError("SignInOnClick: Failed to Sign into Play Games Services.");
            return;
        }
        string authCode = PlayGamesPlatform.Instance.GetServerAuthCode();
        Debug.LogFormat("SignInOnClick: Auth code is: {0}", authCode);
        if (string.IsNullOrEmpty(authCode))
        {
            Debug.LogError("SignInOnClick: Signed into Play Games Services but failed to get the server auth code.");
            return;
        }

        // Use Server Auth Code to make a credential
        Credential credential = PlayGamesAuthProvider.GetCredential(authCode);
        // ......
    });
}

I have watched some videos. I am not sure all of my steps are correct as these video teaches how to build a new app with Google Play Service. But my project is already launched. Some other settings like API Credentials are already done by the others.

I have found someone said that the SHA-1 client IDs of Android should be changed from the "App signing certificate" one into the "Upload certificate" one. Link here.

And I have also found that using web client IDs instead of Android. Link here.

I have tried these fix methods already but seems not work for me. Is anyone having the same problem with me? Or is there any setting displaying more details of this issue?

like image 955
Jacky Hon Avatar asked Nov 06 '22 23:11

Jacky Hon


1 Answers

I had the same issue and solved it by disabling minifying.

"Build" > "Player Settings" > "Publishing Settings" > "Minify", here I set both Release and Debug to None and it was fixed.

like image 159
Alp Avatar answered Nov 15 '22 10:11

Alp