playgameservices / play-games-plugin-for-unity

Google Play Games plugin for Unity
Other
3.44k stars 959 forks source link

mClient getting unauthenticated when I try to open saved game #3031

Closed Jubal-Norman closed 2 years ago

Jubal-Norman commented 3 years ago

Hey everyone

I've been troubleshooting this issue for a little while now. My game successfully connects to google play services (I see the little popup with my name and level etc) but when it actually hits the callback for OpenWithAutomaticConflictResolution it is unauthenticated.

I attached visual studio to my android for debugging and when it calls this line:

        ISavedGameClient savedGameClient = platform.SavedGame;
        savedGameClient.OpenWithAutomaticConflictResolution(filename, DataSource.ReadCacheOrNetwork,
            ConflictResolutionStrategy.UseLongestPlaytime, OnSavedGameOpened);

the mClient.mAuthState is Authenticated

But when it goes into the callback function (OnSavedGameOpened) the mClient.mAuthState is Unauthenticated

What could be causing it to unauthenticate in this time? I haven't seen anyone else with this exact issue (usually they aren't authenticating to begin with) so any help would be great. I'll keep looking and post back if I find a solution. Let me know if you need more info on my setup.

        PlayGamesClientConfiguration config = new PlayGamesClientConfiguration.Builder()
            .EnableSavedGames()
            .Build();

        PlayGamesPlatform.InitializeInstance(config);
        PlayGamesPlatform.DebugLogEnabled = true;
        platform = PlayGamesPlatform.Activate();

----

       platform.Authenticate(SignInInteractivity.CanPromptOnce, (result) =>
            {
                switch (result)
                {
                case SignInStatus.Success:
                    isConnectedToGooglePlayServices = true;
                    saving = false;
                    OpenSavedGame("RollingBagelSave");
                    break;
                default:
                    isConnectedToGooglePlayServices = false;
                    throw new Exception("Didn't sign in properly");
                }
            });
Jubal-Norman commented 2 years ago

Not entirely sure what all changed between when I posted this and now, but the thing that seemed to make it work is making sure that all of the things to access the saved game stuff uses Social.Active instead of PlayGamesPlatform.Instance.