Google Play: Game signs in every time scene resets

Hi guys,

I made an Android game with Google Play services implemented. I tested a game on my device and it worked perfectly well by signing in only once.

When I published the app after testing it like hundreds of times, I tested a game on another device and found out that when the scene resets it signs in the user over and over again.

I thought this is taken care of by Google Play plugin, but apparently I was wrong.

Here is my authentication code:

    void Awake () {
        PlayGamesPlatform.Activate();
    }
  
    void Start () {
        Social.localUser.Authenticate((bool success) => {
            Debug.Log("Process completed successfully!");
        });
    }

I was trying to make it check if user opens the game for the first time, but it didn’t have any effect, in fact it didn’t sign me in at all.

Thanks in advance! :smile:

The only way I can think of is to have a loading scene when the app is opened, that is never called again during the rest of the game session (i.e. first in the Build Settings list and never reloaded).

I’d love to hear from more experienced people about how Google Play services are usually implemented in terms of when to prompt sign in, dealing with connectivity issues and errors etc.

1 Like

I have a scene that just has my game manager object t in it with donotdestroyonload this object does the google stuff and it loads my other scenes in.

1 Like

@cmcpasserby that sounds like a good idea since you can keep track of stuff associated with google play services throughout the game session

Hey Elmar, I’m not an expert either, but the way I handle this situation is simple. Check the code below, I hope it helps.

void Start () {
       if (!Social.localUser.authenticated)
       Social.localUser.Authenticate((bool success) => {
           Debug.Log("Process completed successfully!");
       });
   }

Thank you! I will try it out.