/// <summary>
 /// Test sign in
 /// </summary>
 public void SignIn()
 {
     Auth.SignInAnonymouslyAsync().ContinueWithOnMainThread <FirebaseUser>((task) =>
     {
         CurrentUser = task.Result;
         OnSignIn?.Invoke();
     });
 }
Exemplo n.º 2
0
        /// <summary>
        /// Signs in the user anonymously without requiring any credential.
        /// </summary>
        /// <returns>Task of IUserWrapper with the result of the operation</returns>
        public async Task <IFirebaseUser> SignInAnonymouslyAsync()
        {
            try
            {
                IAuthResult authResult = await _auth.SignInAnonymouslyAsync();

                return(new FirebaseUser(authResult.User));
            }
            catch (Exception ex)
            {
                throw GetFirebaseAuthException(ex);
            }
        }
 public void SignInAnonymously(Action <FirebaseUserResult> callback)
 {
     if ((Application.platform == RuntimePlatform.Android || Application.platform == RuntimePlatform.IPhonePlayer) && !Application.isEditor)
     {
         targetBehaviour.StartCoroutine(ProcessFirebaseUserTaskRoutine(auth.SignInAnonymouslyAsync(), callback));
     }
     else
     {
         WWWForm form = new WWWForm();
         WWW     www  = new WWW(serviceUrl + "/signInAnonymously", form);
         targetBehaviour.StartCoroutine(ProcessWebServiceUserRoutine(www, callback));
     }
 }
Exemplo n.º 4
0
        // Try to SignIn Async
        void TrySignIn()
        {
            _auth.SignInAnonymouslyAsync().ContinueWith(task => {
                if (task.IsFaulted)
                {
                    Debug.LogWarning("Can't create user, retrying in " + (millisecondsToRetrySignIn / 1000f) + " seconds...");
                    Thread.Sleep(millisecondsToRetrySignIn);
                    var instanceCaller = new Thread(TrySignIn);
                    instanceCaller.Start();
                    return;
                }

                Persistence.Log("User created:" + task.Result.UserId);
                Crashlytics.SetUserId(task.Result.UserId);
            });
        }
Exemplo n.º 5
0
    public async void LoginAnonimo()
    {
        PreCadastro();
        await auth.SignInAnonymouslyAsync().ContinueWith(task => {
        });

        if (auth.CurrentUser != null)
        {
            SceneManager.LoadScene("Usuario Logado");
        }
        else
        {
            PosCadastro();
            Debug.Log("Usuario nao cadastrado, tente novamente");
        }
    }
        // [END on_stop_remove_listener]

        async System.Threading.Tasks.Task SignInAnonymously()
        {
            ShowProgressDialog();

            // [START signin_anonymously]

            try {
                var result = await mAuth.SignInAnonymouslyAsync();
            } catch (Exception ex) {
                Toast.MakeText(this, "Authentication failed.", ToastLength.Short).Show();
            }

            // [START_EXCLUDE]
            HideProgressDialog();
            // [END_EXCLUDE]
            // [END signin_anonymously]
        }
 public void FirebaseAnonymous()
 {
     AudioManager.Instance.PlayUISound(UISoundType.Click);
     auth.SignInAnonymouslyAsync().ContinueWith(task =>
     {
         if (task.IsCompleted && !task.IsCanceled && !task.IsFaulted)
         {
             // User is now signed in.
             FirebaseUser newUser = task.Result;
             Debug.Log(string.Format("FirebaseUser:{0}\nEmail:{1}", newUser.UserId, newUser.Email));
         }
         else
         {
             Debug.Log("failed");
         }
     });
 }
Exemplo n.º 8
0
    public void loginAsAnnonymousUser(System.Action <UserInfo> callbackWhenDone)
    {
        if (signedIn == false)                  //only allow to login if it is not logged in
        {
            auth.SignInAnonymouslyAsync().ContinueWith(task => {
                if (task.IsCanceled)
                {
                    Debug.LogError("SignInAnonymouslyAsync was canceled.");
                    //DebugOnScreen.Log ("loginAsAnnonymousUser was canceled");
                    callbackWhenDone(null);
                    return;
                }
                if (task.IsFaulted)
                {
                    Debug.LogError("SignInAnonymouslyAsync encountered an error: " + task.Exception);
                    //DebugOnScreen.Log ("loginAsAnnonymousUser encountered an error: " + task.Exception);
                    callbackWhenDone(null);
                    return;
                }

                user = task.Result;

                Debug.LogFormat("User signed in successfully: {0} ({1})", user.DisplayName, user.UserId);

                Debug.Log("RefreshToken :: " + user.RefreshToken);
                Debug.Log("DisplayName :: " + user.DisplayName);
                Debug.Log("UserId 0:: " + user.UserId);

                UserInfo annonymousUsers       = new UserInfo();
                annonymousUsers.userID         = user.UserId;
                annonymousUsers.username       = user.DisplayName;
                annonymousUsers.firebase_token = user.RefreshToken;

                createNewUser(annonymousUsers);

                callbackWhenDone(annonymousUsers);
            });
        }
        else
        {
            Debug.Log("there is a user logged in already");

            callbackWhenDone(null);
        }
    }
Exemplo n.º 9
0
    /// <summary>
    /// Emits the FirebaseUser on successful authentication.
    /// Emits an Exception if unsuccessful.
    /// </summary>
    public IObservable <FirebaseUser> signInAnonymously()
    {
        if (m_userSubject != null)
        {
            return(m_userSubject);
        }

        /*  Async Subject:
         *  Emits the last item emitted by the source Observable after it's completes emission. */
        m_userSubject = new AsyncSubject <FirebaseUser> ();

        if (m_auth.CurrentUser != null)
        {
            Debug.LogFormat("User signed in successfully: {0} ({1})",
                            m_auth.CurrentUser.DisplayName, m_auth.CurrentUser.UserId);
            m_userSubject.OnNext(m_auth.CurrentUser);
            // late observers get the last cached item too!
            m_userSubject.OnCompleted();
        }
        else
        {
            m_auth.SignInAnonymouslyAsync().ContinueWith(task => {
                if (task.IsCanceled)
                {
                    Debug.LogError("SignInAnonymouslyAsync was canceled.");
                    m_userSubject.OnError(task.Exception);
                    return;
                }
                if (task.IsFaulted)
                {
                    Debug.LogError("SignInAnonymouslyAsync encountered an error: " + task.Exception);
                    m_userSubject.OnError(task.Exception);
                    return;
                }

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

        return(m_userSubject);
    }
Exemplo n.º 10
0
 public void SignupAnonmous()
 {
     auth.SignInAnonymouslyAsync().ContinueWith(task =>
     {
         if (task.IsCanceled)
         {
             Debug.Log("Signup Cancelled!");
             return;
         }
         if (task.IsFaulted)
         {
             Debug.Log("Signup Faulted!");
             return;
         }
         var newUser = task.Result;
         Debug.LogFormat("Kullanıcı başarıyla oluşturuldu: {0} {1}", newUser.DisplayName, newUser.UserId);
     });
 }
Exemplo n.º 11
0
    // Anonim Kayıt Olma
    public void AnonymousSignUp()
    {
        auth.SignInAnonymouslyAsync().ContinueWith(task =>
        {
            if (task.IsCanceled)
            {
                Debug.Log("Canceled");
                return;
            }
            if (task.IsFaulted)
            {
                Debug.Log("Faulted");
                return;
            }

            FirebaseUser newUser = task.Result;
            Debug.LogFormat("Anonim kullanıcı oluşturuldu {0} {1}", newUser.DisplayName, newUser.UserId);
        });
    }
Exemplo n.º 12
0
        private void AnonymousLogin()
        {
            _auth.SignInAnonymouslyAsync().ContinueWith(task => {
                if (task.IsCanceled)
                {
                    Debug.LogError("SignInAnonymouslyAsync was canceled.");
                    return;
                }
                if (task.IsFaulted)
                {
                    Debug.LogError("SignInAnonymouslyAsync encountered an error: " + task.Exception);
                    return;
                }

                FirebaseUser newUser = task.Result;
                Debug.LogFormat("User signed in successfully: {0} ({1})",
                                newUser.DisplayName, newUser.UserId);
            });
        }
Exemplo n.º 13
0
        async System.Threading.Tasks.Task signInAnonymously()
        {
            // Sign in anonymously. Authentication is required to read or write from Firebase Storage.
            ShowProgressDialog();

            try
            {
                var result = await mAuth.SignInAnonymouslyAsync();

                Log.Debug(TAG, "signInAnonymously:SUCCESS");
                HideProgressDialog();
                UpdateUI(result.User);
            }
            catch (System.Exception ex)
            {
                Log.Error(TAG, "signInAnonymously:FAILURE", ex);
                HideProgressDialog();
                UpdateUI(null);
            }
        }
Exemplo n.º 14
0
 public void Login()
 {
     auth.SignInAnonymouslyAsync().ContinueWithOnMainThread(async task =>
     {
         if (task.IsCanceled)
         {
             Debug.LogError("SignInWithEmailAndPasswordAsync was canceled.");
             return;
         }
         if (task.IsFaulted)
         {
             Debug.LogError("SignInWithEmailAndPasswordAsync encountered an error: " + task.Exception);
             return;
         }
         FirebaseUser newUser = task.Result;
         Debug.LogFormat("User signed in successfully: {0} ({1})",
                         newUser.DisplayName, newUser.UserId);
         onLogin?.Invoke();
     });
 }
Exemplo n.º 15
0
    /** 익명 로그인 요청 */
    public void anoymousLogin()
    {
        auth
        .SignInAnonymouslyAsync()
        .ContinueWith(task => {
            if (task.IsCanceled)
            {
                Debug.LogError("SignInAnonymouslyAsync was canceled.");
                return;
            }
            if (task.IsFaulted)
            {
                Debug.LogError("SignInAnonymouslyAsync encountered an error: " + task.Exception);
                return;
            }

            user = task.Result;
            Log(string.Format("User signed in successfully: {0} ({1})",
                              user.DisplayName, user.UserId));
        });
    }
    public IEnumerator LoginAnonymously()
    {
        var task = new YieldTask <Firebase.Auth.FirebaseUser>(auth.SignInAnonymouslyAsync());

        yield return(task);

        if (task.Task.IsCanceled)
        {
            Debug.LogError("Sign in canceled");
            yield break;
        }

        if (task.Task.IsFaulted)
        {
            Debug.LogError("Error Signing in: " + task.Task.Exception);
            yield break;
        }

        var user = task.Task.Result;

        if (user == null)
        {
            Debug.LogError("Unknown error signing in!");
            yield break;
        }

        User = user;

        Debug.LogFormat("User signed in successfully: {0} ({1})", user.DisplayName, user.UserId);
        IsLoggedIn = true;
        LoggedIn.Invoke();

        LogsManager.SendLogDirectly(new Log(
                                        LogType.LoggedIn,
                                        null
                                        ));

        yield break;
    }
    public Task SignInAnonymously()
    {
        return(auth.SignInAnonymouslyAsync().ContinueWith(task =>
        {
            if (task.IsCanceled)
            {
                Debug.LogError("SignInAnonymouslyAsync was canceled.");
                OnSignInFailed?.Invoke();
                return;
            }

            if (task.IsFaulted)
            {
                Debug.LogError("SignInAnonymouslyAsync encountered an error: " + task.Exception);
                OnSignInFailed?.Invoke();
                return;
            }

            user = task.Result;
            Debug.LogFormat("User signed in successfully: {0} ({1})", user.DisplayName, user.UserId);
        }));
    }
Exemplo n.º 18
0
    /// <summary>
    /// 익명로그인
    /// </summary>
    public static void GoogleFireAnonymousLogin()
    {
        PopupManager.Close_Popup();

        if (auth.CurrentUser == null)
        {
            Debug.Log("로그인 안 되어 있음");

            auth.SignInAnonymouslyAsync().ContinueWith(task =>
            {
                if (task.IsCanceled)
                {
                    return;
                }
                if (task.IsFaulted)
                {
                    return;
                }

                user_id = auth.CurrentUser.UserId;
                Debug.Log("익명 아이디 " + user_id);
                BackEndDataManager.instance.Get_First_Data();
            });
        }
        else
        {
            //Set_State("로그인 되어 있음 " + auth.CurrentUser.UserId);
            Debug.Log("로그인 되어 있음 " + auth.CurrentUser.DisplayName + " \n "
                      + auth.CurrentUser.Email + " \n "
                      + auth.CurrentUser.IsAnonymous + " \n "
                      + auth.CurrentUser.IsEmailVerified + " \n "
                      + auth.CurrentUser.ProviderId + " \n "
                      + auth.CurrentUser.UserId + " \n ");

            user_id = auth.CurrentUser.UserId;
            BackEndDataManager.instance.Get_First_Data();
        }
    }
Exemplo n.º 19
0
    void LoginAnonymous()
    {
        auth = FirebaseAuth.DefaultInstance;
        //익명 로그인
        auth.SignInAnonymouslyAsync().ContinueWith(task => {
            if (task.IsCanceled)
            {
                Debug.LogError("SignInAnonymouslyAsync was canceled.");
                //인증 실패 시 화면에 오류 메시지 출력
                return;
            }
            if (task.IsFaulted)
            {
                Debug.LogError("SignInAnonymouslyAsync encountered an error: " + task.Exception);
                //인증 실패 시 화면에 오류 메시지 출력
                return;
            }

            user = task.Result;
            Debug.LogFormat("User signed in successfully: {0} ({1})",
                            user.DisplayName, user.UserId);
        });
    }
Exemplo n.º 20
0
    public static void AnonymouslyAuth()
    {
        Auth.SignInAnonymouslyAsync().ContinueWith(Task =>
        {
            if (Task.IsCanceled)
            {
                Debug.LogError("Firebase Auth - SignInAnonymouslyAsync foi cancelado.");
                TecWolf.System.SystemInterface.Alert("O login da conta foi cancelado.");
                return;
            }
            if (Task.IsFaulted)
            {
                Debug.LogError("Firebase Auth - SignInAnonymouslyAsync encontrou um erro: " + Task.Exception);
                TecWolf.System.SystemInterface.Alert("Erro ao logar conta, verifique Email e Senha.");
                return;
            }

            User = Task.Result;

            Debug.LogFormat("Firebase Auth - Usuário logado com sucesso: {0} ({1})", User.DisplayName, User.UserId);
            TecWolf.System.SystemInterface.Alert("Conta logada com sucesso.");
        });
    }
Exemplo n.º 21
0
    void Start()
    {
        FirebaseApp.CheckAndFixDependenciesAsync().ContinueWithOnMainThread(task =>
        {
            Debug.Log("Firebase Initializing..");
            if (task.Exception != null)
            {
                Debug.LogError($"Failed to initilaize Firebase with {task.Exception}");
                return;
            }
            Debug.Log("Firebase has been Initilaized");
            FirebaseAuthInit();
        });

        void FirebaseAuthInit()
        {
            FirebaseAuth auth = Firebase.Auth.FirebaseAuth.DefaultInstance;

            auth.SignInAnonymouslyAsync().ContinueWith(task =>
            {
                if (task.IsFaulted)
                {
                    Debug.LogError($"Failed to log in Anonymously with {task.Exception}");
                    gm.isOnline = false;
                    return;
                }

                FirebaseUser newUser = task.Result;
                Debug.Log($"User signed in successfully: {newUser.DisplayName} ({newUser.UserId})");
                gm.isOnline = true;
                gm.userID   = newUser.UserId;

                db.RetrieveHighscore();
            });
        }
    }
Exemplo n.º 22
0
 /// <summary>
 /// 匿名認証を行う
 /// </summary>
 /// <returns></returns>
 public async Task <FirebaseUser> SignInAnonymouslyAsync()
 {
     return(await auth.SignInAnonymouslyAsync());
 }
        public async Task <IFirebaseUser> SignInAnonymouslyAsync()
        {
            var authResult = await _firebaseAuth.SignInAnonymouslyAsync();

            return(authResult.User.ToAbstract(authResult.AdditionalUserInfo));
        }
Exemplo n.º 24
0
 // Attempt to sign in anonymously.
 public Task SigninAnonymouslyAsync()
 {
     DebugLog("Attempting to sign anonymously...");
     DisableUI();
     return(auth.SignInAnonymouslyAsync().ContinueWith(HandleSignInWithUser));
 }