Login User with Firebase Authentication

Ufinix Academy
A free video tutorial from Ufinix Academy
Learn programming and app development
4.3 instructor rating • 4 courses • 4,829 students

Learn more from the full course

Xamarin Android Uber Clone App with C# and Firebase

Learn advanced Xamarin Android concepts by building a fully complete and functional Uber Clone app using Firebase

15:26:55 of on-demand video • Updated July 2020

  • Learn to build complete Uber Clone apps (driver and passenger) with C#, Xamarin and Firebase
  • Learn to create, remove, update and delete records in Firebase Database
  • Save and handle data locally using Shared Preferences
  • Learn how to use Google Location and Map services in your Apps
  • Learn to find direction from one point to the other with Google Direction Api
  • Learn to find place address with Location Coordinates using Google Geocoding API
  • Learn advanced usage of C# Lambda Expressions
  • Learn advanced usage and creation of custom C# Event handlers
  • Learn to create and design beautiful User Interfaces
  • Understand how to create Local Notifications using Android Notification Manager
  • Learn to make asynchronous WebCallls using Rest Api
  • Learn to initiate a phone call from your app using Native Intents
English [Auto] So in this case quickly we're going to look at how to log into our app. In previous classes we looked at you know how to save t shirt preferences you know how to save user information to to a fab is database using the hash map. So in this class they just look at how to log into an app right. That's more like the most important thing. Okay. So what we want to do is when we we're logging we want to know what logging is successful we want to jump right into main activity right. OK. So the first thing we're going to do a less always changes to app combat activity so we resolve this by bringing Android support OK. So that was done. The first thing we need to do after this is to declare our is to define our buttons and of course our text input layout and grab a reference of it from logging on XM file. All right. So to do that I would just go ahead and define test immediately out test impure layout okay. Let's resolve this let's bring in Android to support design okay. So now I can not say right. I e-mailed test e-mail and test and I'm going to bring in test computer layout password test and we have a button. So I declared button as well and call that logging button. Right OK. If we need to. So if we're going to be users not by then we need to add it coding into layout to our logging Eskimo file. Right. So okay bring out my solution explorer and Lodi dialoguing file. And we did this as well you know when we're doing user registration. So what to do here is very simple. We just go ahead and grab Android support don't design that we get it. All you need to land. OK and also we'll copy this and paste it here OK. So the next thing we need to do is cognitively I doesn't have a reputation. So let's change that and add an idea instead. So that we can be able to reference it you know logging activity I.D. make all these rules for you OK so now the NSA want to do is to park the entire code the entire design that we had initially into a newly Linear Layout. All right. Kay of course some attributes so let's add some attributes we need to lay out hide which is going to be much better and and we need to add layouts reads which will also be which will also be much apparent so the next thing we need to add to be certain the next thing we need to add the orientation your condition needs to be radical then less carrot less suction the entire coding side of it. The initial design we had Bam and everything works well right. So again. Save this and go back into our logging activity. Okay so let's define in your coding into layer quality roots view so we are done. So now the next thing we need to do is is to reference the text immediately out on the aborting that we define to date was we having early at 5:00. OK so we do that to say email or text or call to text purely out as a cast then we do find you by I.D. resource that Ida that immunities. Therefore password tests we have testing purely out fine for you by I.D. resource. I do do it password tests. So let's get our rude view read view will be equal to quality you need to lay out fine you by I.D. resource don't I.D. don't rude view so they last will be our voting quoted log in button right you will go to log in votes and so we have done and so let's add a click event handler far button so. So we've done with that so we'll one day when we click on logging that's when day logging that's when we'll. So another next needs to grab our email and password from our email text and password 6. So to do that we need to define some variables that we used to taking the value so we define string email and password email will be equal to email and test immune that it detects. Remember that this is a testing layer so it has any details inside of you have password therefore to password test the AIDS test the test. So now we have that of course. Once you do some caveats. All right. We have to set some caveat. We don't want someone to send any wrong e-mail or don't even send an e-mail. All we should be able to tell you that. Yeah what you're pretending is wrong. So to do that. Let's add some caveat it's an if statement. So if email. So if e-mail doesn't contain that's kind of a means that is wrong. Right. Okay. Run it uses it by to inform you that while you provided that the email you provided is invalid. All right. So worldview tell you to please provide provided we. Right. So the duration is going to be short. We're going to show it. And after which return. So the this caveat when a check is is our password. If our password is less then it's characters then how do I tell you to provide provided valid password OK so this checks out. We need to know is acute. Our log in right. So now to execute our logging of course we need to first of all initialize our Firebase and we have the code to do that in registration activity. So we just jump right into this place and grab it. So it is the code for initializing our firebase so basically it's here. Of course we need to bring in resolve some things need to bring in some name species. So we're going to use Firebase. So we now need to define a new fire Abby's authentication too. So we don't need this and we don't need this right. So we just need an instance of if I base authentication right. So how to define these to be global. So we receive firebase of K to bring this in this while in so it is an instance of authentication instance of our indications. So we are we initialized our firebase. We're going to say oh we'll be able to fire base of that instant. Okay. You firebase is already initialized. We just grab the instance or the UTI indication. So now less is a futile logging to do our logging. It's more similar to the way we created a new user as well. So we're going to say a set of thought signing signing with email and password making at POS it's an argument or email and password. OK. So now that won't be all. We need some callbacks right. We need to add some callbacks. So when so when designing is successful. So this means that we need to implement this interface. Ray if you guys remember we created a tax completion on listener. All right here which which I said we can always reuse. So when I had secured a reference of this particular class and we use it to implement this interface right. So while we're going to do here is we're going to define a new task completion Listener Game acknowledged past completion listener. Of course the task completion listener right. So with this we can use it to implement the necessary interface. So now add for failure a failure listener of which we will use the same class or handle it. So now we need to add some event for failure for success within our task completion listener. So to do that we're going to say past completion listen to that success. So if I log in is successful these whatever command to put within this code block is. All right. So once you do when the user logging is successful it's just that our main activity. All right. So when I say start activity type of main activity. When a logging field wants to inform the user that logging has failed. So can I say snug. Why don't make the route view logging field duration show. All right so guys this is it. It's quite simple and straightforward. Okay so that's all that we need to do here. We're going to clean things up. OK so I think that's all we need to do for now right. So we gotta go to our splash bean to ensure that our logging activity starts first OK. So now we're going to need to roll it so less tested. OK so we now need to provide the details of some of the users I'm registered in the past. So can I use it to see if logging would be successful. Okay. So we're going to actually use the information or Edward to see if we can log in. We're going to try a wrong password and to see if we need to see the response and we're gonna try to write password and to see what we're going gonna happen. All right OK so we are now into the app so let's try logging in we and Ward and Jehmu let's call. All right. And let me try to put your wrong password please see the caveat that we said you asked us to provide you a valid pass. All right. So let's let me go ahead and put your valid password boys wrong ok. Seems to have an arrow OK. Seems we didn't we didn't initialize our firebase guys. That's why he's always very good to go through your code before you hit the ground running. So what we're going to do is quickly call the initialized firebase here. We didn't call it we didn't initialize our firebase. Of course everything is going to be No. So now that we've done that let's go ahead and run. OK. So our app is deploying so Happy's loading up OK so let's log in with this user like we intended to do before and the password. Let's just use something wrong. Both valid. Logging so logging feeling so now less used incorrect password which is 1 into 8 places. One two three four five six seven 8. Logging bound as you can see logging was successful. So guys this is just how to use Firebase authentication to you know to logging into the app. OK so guys have you enjoyed the class. I need to encourage you keep going. OK. I know we've really been on the surface for quite a long time but we're going to get into this. Yes I was just a bit after then. All right. So guys thank you for being here. And let's go. Let's view this thing together. See in this class.