Exemple #1
0
    void OnFBAuthCompleted(ILoginResult result)
    {
        Debug.Log(result.ToString());
        if (result.Error != null)
        {
            Debug.Log(result.Error);
        }
        else
        {
            if (FB.IsLoggedIn)
            {
                userAccessToken = Facebook.Unity.AccessToken.CurrentAccessToken.TokenString;
                PlayerPrefs.SetString("FBAccessToken", userAccessToken);

                GameManager.Instance.isLoggedIn = true;
                GameManager.Instance.GetProfile();
                PlayerPrefs.SetString("IsAuthenticated", "true");

                Debug.Log("FB user is logged in");

                StartCoroutine("WaitForUserData");
            }
            else
            {
                Debug.Log("FB user is not logged in");
            }
        }
    }
Exemple #2
0
 void AuthCallBack(ILoginResult result)
 {
     if (!string.IsNullOrEmpty(result.Error))
     {
         status.text = result.ToString();
     }
 }
Exemple #3
0
    private void FBLoginCallBack(ILoginResult result)
    {
        Debug.Log("Result " + result.ToString());
        if (result.Error == null)
        {
            //debugText.text += "Login Success";
            var token = Facebook.Unity.AccessToken.CurrentAccessToken;
            userId = token.UserId.ToString();
            Debug.Log("LoginSuccess" + userId);
            ConnectionManager.Instance.myID = userId;
            //debugText.text += "\n" + userId;
            UserProfile();
#if UNITY_ANDROID && !UNITY_EDITOR
            PlayerPrefs.SetInt("IsFbLogedIn", 1);
#endif
            UIManager.instance.mainMenuUI.gameObject.SetActive(true);
            UIManager.instance.loginPanel.SetActive(false);
            ConnectionManager.Instance.MakeConnection();
            UIManager.instance.fbLoginCheckPanel.SetActive(false);
        }
        else if (result.Error != null)
        {
            //debugText.text += "\n Error" + result.Error.ToString ();
            Debug.Log("Error in Login");
        }
    }
    private void AuthCallback(ILoginResult result)
    {
        if (FB.IsLoggedIn)
        {
            Debug.Log(result.ToString());

            // User.requestLogin (Facebook.Unity.AccessToken.CurrentAccessToken.UserId, m_loginWindows.loginResponse);
            var accessToken = AccessToken.CurrentAccessToken;
            Debug.Log("FaceBook Access Token: " + accessToken.TokenString);

            Credential credential = FacebookAuthProvider.GetCredential(accessToken.TokenString);

            auth.SignInWithCredentialAsync(credential).ContinueWith(task => {
                if (task.IsCanceled)
                {
                    Debug.LogError("FB SignInWithCredentialAsync was canceled.");
                    UpdateErrorMessage("FB SignInWithCredentialAsync was canceled.");
                    return;
                }
                if (task.IsFaulted)
                {
                    Debug.LogError("SignInWithCredentialAsync encountered an error: " + task.Exception);
                    return;
                }

                FirebaseUser newUser = task.Result;
                Debug.LogFormat("User signed in successfully: {0} ({1})",
                                newUser.DisplayName, newUser.UserId);
                DisplayName.text = newUser.DisplayName;
                UserId.text      = newUser.UserId;

                UpdateErrorMessage("FB Signup Success");

                GetFireBaseToken();
            });
        }
        else
        {
            Debug.Log("User cancelled login");
            UpdateErrorMessage("FB User cancelled login");
        }
    }