Welcome back.
Finally, we get to the firebase stuff, the real firebase stuff, which means we are going to see how
to sign up our user and it will be represented here in Firebase.
Therefore, we, first of all, need to set things up in Firebase itself.
So let's go do the authentication here and then add a new sign up Molefe method here or sign in method.
All right.
So there are multiple different methods, as you can see, email, phone, Google and so forth.
So there are plenty of different options here.
And the one that I want to use is email and password, because it's the easiest one for testing purposes.
So let's enable this.
All right, and then let's go ahead and save this.
All right, you can see here under your sign and providers email password will now have the status of
an unneighborly.
You can, of course, enable other options as well, but then you would have to implement them.
And as I showed you in another video, if you want to use any other method, then you can just follow
along here and the guides in the documentation.
So they give you some advice on how to use these different approaches here, Google sign and Facebook
login and so forth.
OK, so now that we have that set up, let's go back to Android studio, because here we can now finally
do the code or at the code, which will do this, the registration.
So here we wanted to register the user in our sign up activity with this registered user function.
And for now, we had this text here, make text or this toast, which is said now we can register a
new user.
But now, instead of just showing this, we want to show, first of all, our progress dialogue so that
the user knows that something is happening.
OK, so let's go ahead and show progress, dialogue.
This is the function that we had in the base activity and our sign up activity is inheriting from it.
And what I'm going to say here is, please wait.
And actually, when you do that, it's always good advice or better to use a string for this.
OK, so let's go ahead and check out our strings.
Do we have that already?
So here on the resources, values, strength, we had this please wait.
Yeah, let's use this.
Please wait, because otherwise, if you want to create this app multi language, then you will run
into errors.
So how do we get the string?
Well, we use Artaud String Dot.
Please wait.
OK, so by this it will automatically show this string here or it will pass the string and.
But it's under resources.
Good string where we then need to pass an art string that place wait.
Just like that.
OK, so this is how we can get the resource, we pass it now.
And now that we let the user know that he has to wait, we can finally do the firebase stuff.
So let's go ahead and do that firebase of.
Get instance and then create user with email and password.
All right, so that's what we want to do.
We want to create the user with an email and the password.
Now, if we want to do that, we, of course, need to pass on the email and the password.
So let's do that.
Let's add the email and password as the two parameters here again.
And then you see, we have a huge connection here.
So stuff is connected.
So first of all, we get the firebase authentication on to our class.
Then we get the instance method here.
We use it, then we use to create user with email password it.
Yeah, method on top of that.
And then we can have another method that we use on top of that.
And you can see there are multiple different options here.
So the one that I want to use is to add on complete listener add on.
And you can see here there are another set of add ons here.
Add on success, listener, failure, listener, a complete list in there and so forth canceled.
Listen.
So I want to use the complete listener, so on complete listener.
And inside of that I can now go ahead and run a task.
So I'm going to pass in a whole code block here with a task so you can see it task.
So task is going to be, first of all, run, hide, progress, dialogue.
So if it was successful, you don't need to show the progress dialogue anymore and you can check if
the task is successful itself.
So this is uncompleted listener.
So once it's complete and here we're checking if it's successful, so if the task is successful, then
let's create a new firebase user.
OK, so this will be a fire based user object.
And what do we get that from?
Will we get it from the task itself?
So we need to import firebase user here and then we can go ahead and use TASC result.
User and all of these are available, so we need to use the double exclamation mark here.
All right, now we have the firebase user and we can also get the registered email, Savol registered
email.
It's going to be a firebase user dot email.
And this is, again, a nullable.
OK, so by this we get the registered email address and for now we can just let the user know that he
has registered with a certain email so we can add a toast here.
So Tost make text.
In this context and then.
Let's say we, first of all, enter the name of the user, you have successfully registered the e-mail
address and then email address.
So user email or how to be college.
Registered email, registered email.
OK, so let's put that into multiple lines just to see here.
What we're doing and of course, we also need to add tost length, for example, let's show it for a
long period of time.
And you know, what we're going to do is we're going to sign out the user again, so Firebase of get
instant sign out.
So just because we don't have anything to do with him yet, but in the future, we will, of course,
do something else.
So for now, let's sign him out and close this activity once we have successfully registered the user.
All right.
And then we have this if task was successful.
Now, let's say the task was not successful.
So what do we want to do if it wasn't successful?
Well, I'm just going to display the error message so tost make text.
And here in this context.
Right, the task exception message.
For a long or let's say a short time this time, length short.
That show.
All right, so this is going to be our.
I don't complete listener.
And here, of course, it's complaining because I have these unnecessary parentheses.
So let's get rid of them.
Those brackets.
All right, so now we have our own copy listener.
At this point, we should be able to test our application and see if we can actually register a user
or not.
All right.
So let's run our application, by the way, if that works, then end users.
So here we should find a new user.
So it will create a new user entry here and we can use or gate users manually here as well.
So that is something that you can do directly in Firebase, if you will, for example, just want to
test to sign in functionality.
And let's say you have an app where only you as an admin can create users.
No one can create a new account.
You have to create the account.
Then you could develop an app like that where you just create a user's manual in here and the user can,
of course, log in.
But he cannot create a new account in the app.
So that is, of course, also an option.
Depends on the use case that you have or on the use case of the customer that comes to you and wants
an app.
OK, so that we are our beautiful sign up screen is there and I think it is fully loaded, right?
Yeah, well it's still running.
OK, let's just give it some more time.
That's important.
That is, it's fully done so that you only test it once it has the latest version which contains all
of this code on the device.
All right, once it's all done, let's see what we get there, so let's say my name is Dennis.
My name is Emeril's.
Dennis had.
Gmail dot com.
And my password is super secure, so let's sign up, please wait, a networker such as Timeout Interrupted.
OK, that's very nice.
Let's try again.
All right, so, yeah, I tried to once again and again, and then at one point it worked.
So it seems like my connection on the phone didn't work or something like that.
So I registered to use her once I pressed it again.
So let's reload the page and you can see the user exists.
So let's try it again with another account.
So sign up, so Dennis, this time, Dennis at Yahoo!
Dot com or whatever, Yahoo dot com and same password, super secure.
So let's sign up again.
Please wait.
And you have successfully registered the email address doneness at Yahoo!
All right, so that worked.
So now let's refresh the page here and we can see we have the new user.
OK, so at this point, you can create the user.
You can see when it was created and you can see that each user gets a new ID.
So this is a user you ID so you you ID if you see that ever, then you know what it is.
It's a user unique id ok so or identifier.
So it's like a very super unique weird combination of characters and numbers.
Right.
So this is how you can then of course morph letters and numbers and this is how you can identify every
single user individually.
So maybe you have multiple users with the exact same email address, even though that shouldn't be the
case.
But for some reason it could happen.
Then you still have the UID or you ID in order to find the user individually or the individual users.
You can also see here the providers who concedes an email.
So this user has registered via email.
All right.
So this is this little icon that you can see here.
All right.
So at this point, you see how you can register a user.
Now, we, of course, want to be able to log in with that user because we are directly signed out by
the application.
At least that's what we developed with this one line we added.
But in the next video, we're going to see how we can actually sign in.
All right.
So let's do that in the next few.
See you there.