rlamasb / Firebase.Xamarin

Light weight wrapper for Firebase Realtime Database REST API.
MIT License
149 stars 39 forks source link

How to check if user has log in? #29

Closed jorxein closed 6 years ago

jorxein commented 7 years ago

Anyone known hoy to check if user log in. Step 1, create user. Step 2, login user. Then close the app Step 3, check if user had log in..

blaiser49 commented 6 years ago

A good way of retaining auth info after closing the app would be amazing! Logging in every time is too much to expect from people..

blaiser49 commented 6 years ago

For now using the Plugin.Settings plugin to retain FirebaseAuthProvider info between sessions and checking token usability each time app is loaded. Once pull request #36 is accepted we will be able to refresh the firebase token when it expires

blaiser49 commented 6 years ago

still waiting on pull request to be accepted :(

Ramonzo commented 6 years ago

Hey dude, you can do it with this code. I put the Label element to show me when I log in or out.

Label label = this.FindByName<Label>("label");
            FirebaseAuth firebaseAuth = new FirebaseAuth();
            User user = firebaseAuth.User;
            if (user != null) {
                label.Text = "Logged";
            }
            else
            {
                label.Text = "No Logged";
            }
blaiser49 commented 6 years ago

How does that solve the issue? The token still is invalid after an hour (3600 seconds) and the user won't be able to use .WithAuth() with any queries when it expires.. unless I'm missing something?

Ramonzo commented 6 years ago

In Firebase for Android Studio will check if user exist in this phone and works. Is persistent like persistent data. Including for notifications for app closed. If somebody fix this, please tell us!!