3
\$\begingroup\$

This question is asked in the context of the Google Play Services plugin for Unity.

Following the documentation for the Google Play Services plugin for Unity, I called the Social.localuser.Authenticate() function in my game to check if the player is authenticated (ie: logged in to google play services).

Here is the authentication code that I am currently calling:

void Awake ()
{
    PlayGamesPlatform.Activate();

    Social.localUser.Authenticate((bool success) => {
        if (success)
        {
            GetLeaderboardData("FirstLoad");
        }
        else
        {
            loadingText.text = "Failed to connect to Google Play Services.";
            StartCoroutine("WaitAndStart");
        }

        authenticated = success; //success returns true even without an active internet connection
    });
}

This works fine with an active internet connection. However, if the player has logged in before, and then launch the game without an internet connection, this function somehow returns true. It doesn't make sense (at least not to me) that the player can authenticate without an active internet connection. Does anyone know if this was intended? (Or if I made a mistake of some sort somewhere?)

Should it have been indeed intended (and the method is checking against a cache of some sort), is there no method to check if the player has an active connection to google's servers? Something along the lines of PlayGamesPlatform.CheckConnection()?

\$\endgroup\$

1 Answer 1

1
\$\begingroup\$

If the user already logged in with the account, the login will be silent and it's possible without internet connection. So, yes, it's intended.

If you want to force the user to have an internet connection, you can check the NetworkReachability

\$\endgroup\$
1
  • 1
    \$\begingroup\$ Correct. And I wanted to add that not only does it remember that the user is authenticated it even allows the user to update online leader boards and unlock achievements. When the internet becomes available everything will sync up. \$\endgroup\$ Nov 22, 2016 at 21:37

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .