android: firebase authentication via phone number automatically authenticates - android

The recently added phone authentication in firebase authenticates has two types of users on successful authentication as provided in the documentation:
Instant verification: in some cases the phone number can be instantly verified without needing to send or enter a verification code.
Auto-retrieval: on some devices, Google Play services can automatically detect the incoming verification SMS and perform verification without user action.
But I would like to authenticate the users on the basis of sending SMS instead. So how could it be resolved. And how can it be determined how the users are getting authenticated. Also in some cases if the user is already authenticated in some other device it automatically gets authenticated in some other device without sending the SMS on either of the devices.
Any help would be appreciated.

Related

Firebase Phone Authentication - OTP received but invalid

I have implemented firebase phone authentication for my mobile application based on react-native and built for android mobiles. The firebase authentication process occurs in the backend (PHP/Laravel) and works properly most of the time. However in some cases, the user registers, receives and OTP, however when inputting the OTP I get an Invalid OTP error (mismatch between the one generated in firebase and the one entered).
The process is as follows:
User registers
OTP is sent
OTP is received
OTP entered automatically on the mobile (I have tried manual input as well)
On success, the user is added to firebase (visible from the user table), and then added to the application user list in our backend
On failure (wrong OTP), the user will not be added to the firebase table and a failure response is sent to our backend and display on the mobile as "OTP Invalid"
In random occasions, we are getting an invalid OTP response even though the input is the correct one received. This is happening with new numbers registering. The same mobile network and provider is being used.
Need to check onVerificationCompleted as on android instant verification can happen which will use another method than success

Registration in Firebase using OTP

I want to make an app in Android Studio where the user will have to register in Firebase using his mobile phone number. But the user would only be allowed to register if he verifies his phone number with the OTP sent to him via SMS.
I don't want to allow anyone with a fake phone number to register and hence I need them to verify. So is there a way to do so in Firebase?
I tried the auth.signInWithCredential() method but it seems to allow users to only sign in with an OTP. I also don't want my users to type an OTP every time they sign in. I want them to sign in using only their password and phone number.

What firebase check Email is valid or not used for new user registration?

I am registering a user in firebase using wrong Email and Password authentication, It register the user successfully and when ask for reset the password it is showing reset mail send successfully on firebase console. Is this is a bug or Firebase does not check wether the eamil is valid or not?
Firebase Authentication does not automatically send verification emails. This is not a bug, since there are many scenarios where such an email may be unwanted or unnecessary.
If your app requires that the user's email address is verified before they can use you app, you will have to send it by calling sendEmailVerification from your app before allowing them access.

How to allow email id to receive OTP in firebase for authentication

I am developing an app wherein the users use either email and phone to perform registration.
Users can enter their email or phone for log in, I want the same OTP to be sent to mobile and email simultaneously. Please Help!
If you want to work only with Firebase Authentication, then there is not any suitable solution that meets your requirement.
Some limitations you can find with Firebase are Firebase Authentication Limits and Phone number sign-in limits.
However the alternative solution is using third-party SMS gateway. through with you can send OTP to phone number as well as to email also simultaneously.
Lets assume you already have mechanism to generate OTP and verify OTP from android app.
Now the problem is how to send OTP to the user's email.
One of solution is using MailGun service to send email from your backend.
Also, if you want to templating your email, you can use library called handlebar

Firebase Phone auth by call

Suppose I need to verify users by Firebase phone authentication.
But somehow, user is not getting otp sms. So does firebase gives the option to get the OTP by receiving call?
You can use Firebase Authentication to sign in a new user by sending an SMS message to his phone, he would then receive a verification code to his phone number via SMS which would then allow him to sign in if the code is correct. However it's not possible yet to give the user his verification code via a voice call. Maybe they will do it in a future release ? It would be great indeed !

Categories

Resources