Search code examples
androidauthenticationloggingunity-game-enginegoogle-play-games

Google Play Game Service Check user logged in or not Unity3d


I want to check user has been logged in or not if it has been logged in then i will check for achievement.

I have written like this :

 void Update()
    {
         Social.localUser.Authenticate((bool success) => {
               Social.ReportProgress("Cfjewijawiu_QA", 100.0f, (bool success) => {
                      // handle success or failure
               });
         });
    }

Here if user is not logged in then it will continuously asking for logged in.

To prevent that i just want to check user has been logged in or not.

How to do this ?

Thanks,.


Solution

  • One solution is to do this in Start(). This way the authenticate method is only called once vs. on each frame.

    To answer your question, you can use the authenticated property:

    void Update()
        {
             if (Social.localUser.authenticated) {
                   Social.ReportProgress("Cfjewijawiu_QA", 100.0f, (bool success) => {
                          // handle success or failure
                   });
             }
        }