Register a New 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,828 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 guys welcome to this class. So in this class we're gonna be looking at how to register a new user using a firebase authentication. Right. So this is where we start the last class. All right. We designed our logging registration pages all right. So we're going to top it up a notch. So to dive in. The first thing that we need to do is to reference our test imput layout and our button in our registration activity. All right. So you guys already know how to do that but let's just go ahead and do it together. All right. So we'll have to define an instance of text impute layout so we need to resolve this and bringing Android Android suppose design. All right. So we're going to call this to the test D for the funding. So the next one is going to be is going to be full text. The other one is going to be for our e-mail and the last one is going to be for our password. Now we are done with this. We need to of course define our button as well. We call this register button OK so now we are done with that. We want to actually reference the instances of these controls to their ones that we defined in our exam. All right. So I actually like keeping things pretty clean. OK. So I'm going to define a separate method. We will be referencing you know our control all right. So say avoid awkward mental coordinates controls. All right so to reference our full name tests we do this right cast test and you lay out nicely defined view by I.D. resource the I.D. go its full name test which yesterday has actually become a lot smarter fun test will be able to test immediately out find view by I.D. resource. No I.D. that phone test. So the next will be e-mail test. We'll be able to test immediately out find your I.D. resource I.D. thoughtful test sorry immune test Rhonda OK now we know this is done. So the nurse would be for Password Password tests to be able to they seem to be out finally you by I.D. restores I.D. the password test OK therefore registered boats in to be a positive customer but in plain view of I.D. resource no I.D. use tablets. OK. So now that we done with that the next thing we need to do is to bringing the package do not get package for firebase authentication so to do that we head over to package manager and download a package and download the nugget package for firebase authentication because this is very important for us to be able to register a new user. All right so that's such for Zeman and Firebase and these the one that we looking for. So we click install to install it assembly licenses and this is done. So now we head back into our app this is installed. We hand back into our registration activity. All right. So what we need to do now is to bring in families authentication you know to be able to register new user. And of course bringing fab is database we can save some of the information that the user will be providing. All right. So let's go ahead and bring in our firebase name species. All right so using firebase that of using firebase database and of course using firebase so now want to define a new instance of Firebase authentication and Fabio's database. So if you do that to save firebase what the call that end of this would be the instance of our Firebase and the institution and I'll be using draft registration activity. So now we define a new instance of Firebase that eBay's right. We call that database. OK so now the next thing we need to do is is to initialize Firebase and if you remember we've done this in formal classes so to speak then. So I would just go and copy the code that we used to initialize firebase in our main activity. All right. So here is the code savages. Copy initialize database. And of course we'll make some edits to it as well. All right so we copy this. Come back here. I'll paste it here. All right. So like I said before guys this is a method of a different way of initializing firebase classifier avenger. Something didn't work so well and it didn't. These didn't initialize they have in this way to force firebase to initialize. So this is very very important and very useful as well. All right. So we are going to make some changes of course we don't need this. We just delete that. OK. So now we call these sort of having databases we can call it initialize firebase. All right so when this happens this is this will actually initialize our Firebase and of course you know get a reference of our database to the instance of our firebase app. All right. So what we need to do now is to get a reference just the way we have a reference database to the instance of AB We need to do this for our authentication as well. So now that we have the method that initialize our firebase we need to call this mental in our own creed. All right. So we say initialize firebase. So after initializing firebase we need to get an instance of our authentication. All right. So when I say m off we'll be able to Firebase off that instance. All right. So now. So now that this is done the next thing we need to do is. So now that we're done with this we need to head over to our families console and enable assigning mentors. All right. So we need to enable firebase to be able to allow us to register new users with email and password. So let's go to the console and enable that. All right. So to do this we need to go into authentication. Right. So we need to set up a sign in the right. So we need to enable e-mail and because it is the one we want to use. OK so we hit enable and save all right. So when we've done this or can now be able to register new users with e-mail on password. So guys also ensure that this is in all right. So now let's head over back into vicious to do and implement it. So now that we are done with it then that's where we need to do is to create an event handler for our register button so that we can now start writing the codes that will allow us to register a new user. So to do that we say register button the clique then hit tab. Right. So a new events handler has been created for us. All right so once you keep these clean so now the next thing to do guys will now be to start taking the values that our user will provide. You know from our logging form our registration page. So to do that Leslie you find new string variables. OK so we define for name and phone and email and password. OK so now that we're doing that we need to start taking these values from our text impute. OK. So to do that when I see full name we'll be able to name test that did test the test. OK so the next one will be for phone. So phone so phone number we'll be able to phone test that. It did test the test. OK. So the next one for e-mail we'll have e-mail test that you did test the test. So the last one for password will be of course to password test don't test their test so in this way we now hold the values that are used as being imputing inside these string variables. OK so now won't allow users to provide any kind of values we needed to use his name. We need it to be a valid name. We need to check the validity of the phone number and the e-mail. And of course the password. So to do that guys let's write some if statements. OK so if a full name. Hey valid name should be up to three characters. OK. So let's say four named land is less than three. OK so we need to we need to use a snack bar to inform our users that this re entry invited me. OK. So to use this number we need to act accordingly to lay out to register accent. All right. So let's how into a layout design our readers are layout and art coordinate on here. OK so to do that we change these two Android don't support don't design do don't we get those called you need to man. OK. This should be copied to see. So now we're having orientation. OK let's change this let's add a 90 so that we can reference it qualities roots view OK. So we need to these to the down part OK. No. Good. So now we need to suction the entire of our code inside a linearly our just the way it was before. All right. So let's define a linear layout in India. Let's add some attributes Android orientation orientation should be a radical and now tight should be much variant now tweet should be much variants as well. OK so we need to copy the entire of our code into these linear layout. OK OK. Now everything is back to normal. So now that we have our code in Italy we can now use that by you know to tell our users that the names that we provide is invalid the email is invalid or whatsoever. OK. So now let's head back into our restriction activity and get it reference of our code in Italy. OK. So just the way we did this we just defined an. So records need to lay out continental air quality rule view OK. So you know connect controls Oh use I did hear Rudy v you would be equal to listening this mistake quite literally out of find the Dubai I.D. resource radio world view. OK so now we are done with this. So we'll head back into our registered Watson Klieg event Hanna. So when the full name is Liz anything you want to say something to use our right to want to say no use no. Don't make rude for you to say please into these into my need invalid name right. And we need to make it short so it doesn't take a lot of time in all right snack bar meant short no show going to happen. So one two is it D. That's what I meant. Ok so I receive if a form is valid for number I should be up to these main characters right. So we have that linked so if our lens is less than nine we do this in being Please enter a valid phone number because the drivers need to call you right. So we need a valid phone number. US if a valid email address should contain ads. OK so anyone that doesn't contain act is probably in an invalid email address. All right. So let's say if not mean that contains not one until you use it to provide invalid e-mail OK. So then I don't want to check is one or the strength of our password. Of course a strong password should be at least up to each character. Okay so we say Alice Eve password Lent is less than eight. OK so we need to tell the user to please enter a password up to eight characters. OK. OK OK. So now that we don't we that DNA stay we need to do is to is to go ahead and start registering to use them. Right. So like I always said I like making things very explicit and clean. So I'm going to create in your mental I'm going to be using to really start a user I need to call these a matter register user. OK. And of course I need some argument I have to pass it a string of name name string phone the immune and of course my password. All right OK. Good so now to register. So T.J. you said a user. We going to say don't create new user e-mail on password right. So you know by say e-mail and password so want to inform ourself if the user registration is successful or failed. So go ahead and add on complete on task completion listeners all right which includes the success listener and feel your listener right. So let's add on success listen. All right. This and this. Okay so an odd failure. Listen as well. This passive and activity and of course is asking for on failure. Listen. All right. This okay. So now to do it this is an interface that we need to implement. Okay so we need to head over to our our recession activity and implement AI on success listener so we need to bring in the reference for this okay. Okay. So we implement the interface so when we implement the interface when the user registers and this is successful whatever we put here will be easy. You did all right but most of the time I don't like handling this thing this way. All right. So what I'm going to do is I'm going to create an anonymous class that will implement these interface and this class will always be reusable from anywhere within a provincial essay in our logging will possibly may need to do some complaint that listeners may need to handle some success or failure starts. All right. So we'll just go ahead and reuse that particular class. All right. So I'm not going to implement this interface in this place. All right so I'm going to remove what I have here. So guys this most of the time I saw phase within the app. OK. Is very useful. I like doing it this way. So to do that I'm going to create a folder I'm calling event listeners. OK. Need to add a new folder call event listener listener. OK. So inside of this place I'm going to create in your class so it is class I'm going to call it task completion listeners listen. OK so it is task completion listen I will fire on events that we inform us when it acts or is successful when it backs field. All right so attendees and probably. So if you guys remember in Ari's in this interface you can resent so you can see that is an argument of Java blunt object. So the task completion I know numerous clients that we are creating will have to you hear read from this class. Okay. So to do that we will head into these particular class and we hear read from Java not long notes objects. Okay. So now we're going to implement EI on success listener Okay so we're going to bring in the references. To the next thing we need to do is of course we're going to implement the interface. So those two guys is this simple and straightforward. And also we can't go ahead and implement it. Phil you're listening as well. So I say I feel your listener. Okay I have that. So I implement the interface so now to keep things pretty clean I will use an event I'll create an event handler. Probably even luck. That can always send me feedback of whether our tax was successful or failed. All right so I'm going to define a public event event handler. I'm going to call my event handler success and do you find another one I'm going to call this failure. All right. When our task you feel it so we're going to invoke this event. All right. So it will notify our roads class. That's the task that we are listening to. Josephine. All right. So to do that we say fairly or we'll check for no invoke this new even x pretty simple shorthand so we can do that for success as well. So we say success let's invoke success but invoke this new event as right. Okay so now we're done. So let's go back into our registration activity and clean things up. All right. So we no longer need this and we don't need this interface as well. So now what I'm going to do will be to not create an instance of that completion list in it. OK so to do that let's come here and say past completion completion listener so we're gonna bring a reference of that you know being the reference of that we're going to use that and they call this task completion and listener code to new task completion listener. OK so now these really are going to use that. All right. So you said Oh yeah I'm supposed to use this SOC says listen that we use that's completion on listener in that in that place. All right. For the failure I'll use task completion listener. All right. So to handle callbacks when the creation of a user was successful. What I'm going to do I'm going to say that's completion listen and our success. So you guys going to see that event create it have this bomb. So when are attacks is completed and when is successful then anything we do here will serve as a callback to is acute. So whenever I create to use a successful. All right. So whatever code whatever command we'll put here is acute. OK. So in that same vein less and the same thing for failure right. So we'll have it for failure. OK so what do you want to do when we were registration was successful. OK. Yes. Two things we could do. We could use not bar don't make to view and tell us that use a registration was successful this is short and sure. OK so in this way so in this way we'll be informed will we be notified when they use as the decision was successful. OK so let's do the same thing for failure. So what do we want to do. When did recession or failed want to inform us. Once they informed us that the recession was so when I said musician field so bums. So this is roughly what we need to do so without much ado let's go to our splash activity and ensure that is recession is registration activity that starts first. Okay. Obviously is what's that phase. So going forward in other classes we'll see how to you know automate this so that it could always know we had to start from. All right. So now that we are done with everything that is necessary we now need to call these circular metal in our boating events Klieg so to do that. Majors go Uncle D met dog here radio star user and of course we'll pass our name was a plus. Full name our. Immune and possible okay. Musically all we need to provide and we are done. So guys in this day we need to do is ensure that everything checks out. Well. So last we need to do is to have a second look through our code and see if there's anything we need to change. Okay so we need to call a d control on treatment metal to ensure that controls. That's our texting Julia. The buttons and all those of our well connected. Okay so we're gonna call this connect control here to ensure that our controls are well referenced. And I think that's all that needs to be done. All right. So the next thing we need to do is to deploy the app and debug it and ensure that everything works perfectly. So guys let's just run our app and see it in action. Okay. Tribute that end app is loading up okay so let's see if these are caveats the kind of guys that will set up our new walking Inc okay. His entire valued me your phoenix so an equity phone number okay. Isn't making the invalid intention in me his entire valid phone number. So this works so well so let's impute our email address okay. So guys as you can see this works just very well. Okay so let's just go ahead and test our registration and ensure that everything checks out. Wow okay so we can register so bam user registration was successful. So guys to confirm that we'll have to head into our largest had allowed to fire base. Of course we'll refresh our authentication and you can see you guys you Phoenix Academy has been registered. Okay so guys this is just how to register a new user with families authentication. So now we need the information of the user in our database. Okay. We need the information in hand so that we can always assessing. We just reduced that to user. But we need some of the information here. All right. So in our next class guys we'll be looking into how to save our data to a firebase using hash mark. OK. So guys see you in this class.