Example #1
0
    private void SignInNoSilent()
    {
        AN_GoogleSignInOptions.Builder builder = new AN_GoogleSignInOptions.Builder(AN_GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN);
        builder.RequestId();
        builder.RequestEmail();
        builder.RequestProfile();

        AN_GoogleSignInOptions gso    = builder.Build();
        AN_GoogleSignInClient  client = AN_GoogleSignIn.GetClient(gso);

        AN_Logger.Log("SignInNoSilent Start ");

        client.SignIn((signInResult) => {
            AN_Logger.Log("Sign In StatusCode: " + signInResult.StatusCode);
            if (signInResult.IsSucceeded)
            {
                AN_Logger.Log("SignIn Succeeded");
                UpdateUIWithAccount(signInResult.Account);
            }
            else
            {
                AN_Logger.Log("SignIn filed: " + signInResult.Error.FullMessage);
            }
        });
    }
Example #2
0
    private void SignInFlow()
    {
        AN_Logger.Log("Play Services Sign In started....");
        AN_GoogleSignInOptions.Builder builder = new AN_GoogleSignInOptions.Builder(AN_GoogleSignInOptions.DEFAULT_GAMES_SIGN_IN);

        //Google play documentation syas that
        // you don't need to use this, however, we recommend you still
        // add those option to your Sing In builder. Some version of play service lib
        // may retirn a signed account with all fileds empty if you will not add this.
        // However according to the google documentation this step isn't required
        // So the decision is up to you.
        builder.RequestId();
        builder.RequestEmail();
        builder.RequestProfile();

        // Add the APPFOLDER scope for Snapshot support.
        builder.RequestScope(AN_Drive.SCOPE_APPFOLDER);

        AN_GoogleSignInOptions gso    = builder.Build();
        AN_GoogleSignInClient  client = AN_GoogleSignIn.GetClient(gso);

        AN_Logger.Log("Let's try Silent SignIn first");
        client.SilentSignIn((result) => {
            if (result.IsSucceeded)
            {
                AN_Logger.Log("SilentSignIn Succeeded");
                UpdateUIWithAccount(result.Account);
            }
            else
            {
                // Player will need to sign-in explicitly using via UI

                AN_Logger.Log("SilentSignIn Failed with code: " + result.Error.Code);
                AN_Logger.Log("Starting the default Sign in flow");

                //Starting the interactive sign-in
                client.SignIn((signInResult) => {
                    AN_Logger.Log("Sign In StatusCode: " + signInResult.StatusCode);
                    if (signInResult.IsSucceeded)
                    {
                        AN_Logger.Log("SignIn Succeeded");
                        UpdateUIWithAccount(signInResult.Account);
                    }
                    else
                    {
                        AN_Logger.Log("SignIn filed: " + signInResult.Error.FullMessage);
                    }
                });
            }
        });
    }