Javatpoint Logo
Javatpoint Logo

Sign-In Authentication Using Phone Number

Phone number authentication is the last sign-in method, which we will discuss in the authentication section. Many organizations widely used these authentication method.

We can use Firebase authentication to the sign-in user by sending a text message to the user's phone.

The user will sign-in using a one-time code that they have received in their message box.

We will go through the whole flow that how we can verify it and write all the code for that. For sign-in authentication using the phone number, we can also use the Firebase UI, which we have discussed earlier.

Starting steps are the same, such as creating a Firebase project, creating an Android Studio project, adding firebase to our Android app, adding firebase-auth and firebase-core dependencies, adding SHA-1 and SHA-256 keys, add JSON file, and apply plugins. The next steps are to enable phone number authentication in Firebase console. After these preliminary steps, we have to perform the following steps:

Step1:

Now, we will add permission to use the Internet in our Manifest file.

Step2:

Now, we will modify our 'activity_main.xml' file for phone number authentication. The layout design will be as followed:

Sign-In Authentication Using Phone Number

Step3:

Now, we will code for the phone number authentication. We will modify our 'MainActivity.java' file. Below is the code for the phone number authentication.

Output:

Sign-In Authentication Using Phone Number
Sign-In Authentication Using Phone Number





Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA