Firebase Phone Authentication .NET MAUI (Android)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hello guys in this video I am going to show demo about implementing Firebase phone authentication in dot net for Android platform so let's go through it so here first we need to install one plugin in our Android project so let me install here in format project in a dependency of Android here I'm just going to click on manage new get packages and here I am just going to search for this tamarind.firebase dot dot plugin and that I am just going to install here in Android project so far for iOS you need to install this plugin and for Android you need to install this plugin okay so this plugin is installed now I am going to add this phone authentication application in a Google Firebase console so for that I am just going to open Google Firebase console here you can either create new project or open existing project so here I'm just going to open this project just click on this uh plus icon and select Android option so here you need to add package name and this ss1 debug signing certificate so this will use for testing phone authentication so let me just add package name here so for adding package name just right click on your project and just click on properties so here in a debug option you will see this application ID so this application ID you just need to copy add here in a Firebase console now for getting deep signing certificate you just need to add this command in command line so here in command prompt I'm just going to add this command so it is going to show me this asset even debug signing certificate debug signing certificate key so this I'm just going to copy and add here in debug signing certificate or such a one now just click on this Register App option and now you can download this Google service Json file Android application okay so here in a platform project I am just going to add this Google service Json file now right click on this Google service Json file and click on properties and this will add accent you need to set as a Google service Json so this option you need to select now here the main activity.c is you need to initialize Firebase app so for that here you know one create method I'm just going to initialize Firebase app Dot initializer so now I can use Firebase authentication Service after this initialization so here now I am going to create services in upon Authentication so I'm just going to add one interface authentication Service interface here I just added and one method I'm just going to create authenticate mobile and here I'm just going to pass mobile number now here in a platform Android I'm just going to add new folder services and and in that I'm just going to create class the name of this authentication Service so this class is going to create here and this going to inherit I authentication Service interface okay and this name space I am just going to set common so we can use here in iOS as well as Android so what are the namespace here I used uh that namespace I'm just going to use here for notification dot services this same folder I understand I am just going to copy copies project okay now here in Mario program.cs I'm just going to register these services and this service authentication Service I am just going to use here in a main page so for that also I'm going to register main case here so I can access this authentication Service here in main page now here in a main in this Constructor I'm just going to use this authentication Service now here in UI I'm just going to add the text box so I'm just going to remove this all code from here so one entry here I am just going to create so that will user will enter here mobile number foreign this button is going to be submit button so here on a submit button I'm just going to invoke this authentication Service dot authenticate mobile and here I will pass txc mobile number dot tax foreign then you can display here a message like presenter mobile number something like that now here in Android authentication Service class I am going to implement another class here for phone font provider on verification stay change callbacks it will implement it is in completed and on verification field so here I am just going to add now code related to sending verification code to particular mobile number so first I'm just going to create dot option Builder so it's set phone number so here I can specify what is the mobile number I pass that I can just pass here then set timeout so you can set here timeout so I'm just going to set here 16 seconds so this timeout accepting argument in form of java language you are long so that's the reason I did here type casting and here timeout you need I am just going to specify seconds that here set activity set like a platform dot current activity and here inside callback I set this current class so now this will send code to particular mobile and after that it will invoke either this matter like if the verification is completed then this method will invoke if the verification failed then this method going to involve provided dot verify phone number I mean that this hot option I can specify what are the configuration I have set here now let me create here one task completion so so based on that we can decide either the verification code is sent or not foreign when I call this method then I'm just going to initialize it and that I'm just going to return so now here on verification failed I'm just going to set result too false okay and here on a verification complete you can just display some message like a verification is completed in this method and here I am going to also write one method old sand so when the code is sent successfully that time I'm just going to set this verification code completion source to true okay so this on code sand method is going to return validation ID that we can use for validating whatever code user input in UI so with the combination of verification ID and the user inputted code we can validate the OTP now this verification idea I'm just going to create here very private variable this verification idea I'm just going to store here now let me add one method here in authentication Service like validate OTP and here I'm just here going to enter I'm going to pass here whatever the code that user please use so this matter now I am going to implement here in Android project so first I am just going to check like is the verification ID is available if it is available then I'm just going to get credential using phone or provider dot Capital NCL so here I need to pass verification ID and the SMS code so verification ID we already stood when the one code send method is executed that time we are receiving this ID into this variable and whatever the user pass the code at V2 into passing this method get credency now here now I'm just going to sign in with credential and this credential I am going to pass here let me create one variable here so here I would check like if the task is faulted or is canceled so if a user inputted code is not valid then I will just set this return value false and I'm just going to written from here otherwise I just set return value to okay now I can call this method to verify the OTP so now here in UI here in the main page I am just going to add to layout one uh first in this vertical State layout I am just going to set name is and other vertical panel that for verification so here on the BTN verify code I am just going call this new created method validate OTP and in that this code I am going to pass so by default I will just set this panel visibility to files so here in the main page the demo.cs now I'm just going to check like keep this response authenticate mobile [Music] okay so here in Android this method authenticate mobile is going to return true if the mobile number is inputted mobile number is valid so if it is valid valid mobile and code sent to particular device in that scenario I am just going to set this panel visibility to true and this panel mobile info visibility to files and here in BTN very verified code clicked I'm just going to check here like here I will call validate OTP method and in that I am just going to pass this exec code.tax so this matter either going to return true if the code is validated then it's the screen to return true otherwise it's just going to return false foreign user inputed code is valid I am just going to add here one page in this project dot net Market content page okay so when the code is valid I am just going to navigate to this new page one okay now here in a higher page console you need to do some settings so first here in a build option in our Authentication you need to add Here sign in method so here add new provider and select phone I already added here after adding that you can add here testing device number so I have added like this testing device and verification code so using this number I can paste like whether this Pawn authentication is working or not and another thing you need to do that here in app check so go to build option and select app check and here in apps you will see like what is the application you added there you just select your application and just add here sha 256 certificate fingerprint so you will get like we already use this command so it displaying assets one signature as well as Sha 256 fingerprint so this you need to add here after that it's just going to work so you just add that signature here I'm going to add this command in a description or video link so you can just use this command to get this fingerprint detail foreign [Music] foreign okay so I cannot add anything by just going to show this error message and add invalid number and this Firebase is going to display this Center valid number message okay now let me just try to add some valid number so that we have added from here in testing so this number I'm just going to use okay so now code is signed so that another panel is displaying so we just set this panel visit blade it to true and let me just change this text to verify so it will not create confusion okay now if I add first invalid verification code so here in sign in method I just added that my code is one two three four five six so if I add any invalid code then it is going to display this message enter valid code and if I add valid code then it is going to verify and navigate to this new page okay so let me try to test in uh some valid mobile number okay so here I'm just going to submit okay so it's a resume valid OTP let me just check okay so when I enter value.ap it's navigated to new page one okay so here another thing I want to say that here I have used this sh1 uh fingerprint and SSH 256 uh fingerprint from the debug environment so like when you create a valid uh keystore like whatever the key story you use for release app that key store detail you need to add here in uh this Firebase console like while adding application when you add Android application so that time we added sha one fingerprint detail so that you just need to add or you can from here also you can delete and add that assets even an asset to 56 fingerprint detail and also you need to do one thing like you need to enable Android device check API [Music] documentation you will get this like you need to enable Android check device check API so I already enabled to paste that so after that it is going to work okay so that's uh all for today I hope you like this video and thank you so much for
Info
Channel: Programming With Pragnesh
Views: 3,741
Rating: undefined out of 5
Keywords: Phone Authentication In .NET MAUI, Firebase Phone Authentication, OTP Verification In .NET MAUI, Phone Authentication In .NET MAUI (Android), .NET MAUI Android
Id: EJgBCar4ZZY
Channel Id: undefined
Length: 29min 9sec (1749 seconds)
Published: Sun Dec 11 2022
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.