コード例 #1
0
        public UM_AndroidSignInClient()
        {
            SA_MonoEvents.OnApplicationPause.AddSafeListener(this, (paused) => {
                if (!paused)
                {
                    //We do not want to do Silent SignIn on resume in case player not yet signed.
                    if (PlayerInfo.State == UM_PlayerState.SignedOut)
                    {
                        // In case it's not null, this means we are missng something, so we will do  Silent SignIn
                        // The case may happend because we sending fail event on propxy Activity Destory event.
                        // But propxy Activity Destory not always means that player is failed to log in.
                        // We have to send fail evennt on propxy Activity Destory, since if we not, in cases where google and our proxy
                        // activity both are destoryed, we will not get any event.
                        if (AN_GoogleSignIn.GetLastSignedInAccount() == null)
                        {
                            return;
                        }
                    }

                    //We need to perform Silent SignIn every time we back from pause
                    SignInClient.SilentSignIn((silentSignInResult) => {
                        if (silentSignInResult.IsSucceeded)
                        {
                            RetrivePlayer((result) => { });
                        }
                        else
                        {
                            //looks Like player singed out
                            UpdatePlayerInfo(null);
                        }
                    });
                }
            });
        }
コード例 #2
0
        public bool IsSignedIn()
        {
            if (!IsGoogleApiAvailable)
            {
                return(false);
            }

            return(AN_GoogleSignIn.GetLastSignedInAccount() != null);
        }
コード例 #3
0
 public override void Test()
 {
     if (AN_GoogleSignIn.GetLastSignedInAccount() != null)
     {
         SignInClient.SignOut(() => {
             SignIn();
         });
     }
     else
     {
         SignIn();
     }
 }
コード例 #4
0
        public void GetSignedInPlayerData(Action <AN_Player> resultCallback = null)
        {
            if (!IsGoogleApiAvailable || AN_GoogleSignIn.GetLastSignedInAccount() == null)
            {
                return;
            }

            if (_currentPlayerData != null) //early exit with existing player data
            {
                //Printing player info:
                Debug.Log("player.Id: " + _currentPlayerData.PlayerId);
                Debug.Log("player.Title: " + _currentPlayerData.Title);
                Debug.Log("player.DisplayName: " + _currentPlayerData.DisplayName);
                Debug.Log("player.HiResImageUri: " + _currentPlayerData.HiResImageUri);
                Debug.Log("player.IconImageUri: " + _currentPlayerData.IconImageUri);
                Debug.Log("player.HasIconImage: " + _currentPlayerData.HasIconImage);
                Debug.Log("player.HasHiResImage: " + _currentPlayerData.HasHiResImage);

                resultCallback.SafeInvoke(_currentPlayerData);

                return;
            }

            AN_PlayersClient client = AN_Games.GetPlayersClient();

            client.GetCurrentPlayer(result =>
            {
                if (result.IsSucceeded)
                {
                    _currentPlayerData = result.Data;

                    //Printing player info:
                    Debug.Log("player.Id: " + _currentPlayerData.PlayerId);
                    Debug.Log("player.Title: " + _currentPlayerData.Title);
                    Debug.Log("player.DisplayName: " + _currentPlayerData.DisplayName);
                    Debug.Log("player.HiResImageUri: " + _currentPlayerData.HiResImageUri);
                    Debug.Log("player.IconImageUri: " + _currentPlayerData.IconImageUri);
                    Debug.Log("player.HasIconImage: " + _currentPlayerData.HasIconImage);
                    Debug.Log("player.HasHiResImage: " + _currentPlayerData.HasHiResImage);

                    resultCallback.SafeInvoke(_currentPlayerData);
                }
                else
                {
                    Debug.Log("Failed to load Current Player " + result.Error.FullMessage);
                    resultCallback.SafeInvoke(null);
                }
            });
        }
コード例 #5
0
#pragma warning restore 649


    //Avoid using API with Awake. The main Android activity may not be ready yet.
    private void Start()
    {
        AN_Logger.Log("AN_GMS_Auth_Example Start");
        //Let's see if user has already signed in
        var signedInAccount = AN_GoogleSignIn.GetLastSignedInAccount();

        if (signedInAccount != null)
        {
            //That's good but we need to re-connect anyway

            SignInNoSilent();
            //UpdateUIWithAccount(signedInAccount);
        }

        /*
         * m_checkAvalibility.onClick.AddListener(() => {
         *  int result = AN_GoogleApiAvailability.IsGooglePlayServicesAvailable();
         *  if (result != AN_ConnectionResult.SUCCESS) {
         *      Debug.Log("Play Services does not available on this device. Resolving....");
         *
         *      AN_GoogleApiAvailability.MakeGooglePlayServicesAvailable((resolution) => {
         *          if (resolution.IsSucceeded) {
         *              Debug.Log("Resolved! Play Services is available on this device");
         *          } else {
         *              Debug.Log("Failed to resolve: " + resolution.Error.Message);
         *          }
         *      });
         *  } else {
         *      Debug.Log("Play Services is available on this device");
         *  }
         * });
         *
         */


        m_connect.onClick.AddListener(() => {
            var account = AN_GoogleSignIn.GetLastSignedInAccount();
            if (account == null)
            {
                SignInFlow();
            }
            else
            {
                SignOutFlow();
            }
        });
    }
コード例 #6
0
    //Avoid using API with Awake. The main Android activity may not be ready yet.
    private void Start()
    {
        AN_Logger.Log("AN_GMS_Auth_Example Start");
        //Let's see if user has already signed in
        var signedInAccount = AN_GoogleSignIn.GetLastSignedInAccount();

        if (signedInAccount != null)
        {
            SignInNoSilent();
        }



        var account = AN_GoogleSignIn.GetLastSignedInAccount();

        if (account == null)
        {
            SignInFlow();
        }
        else
        {
            SignOutFlow();
        }
    }