I have a use case where I need each user to be identified by a phone number, this is because my shops will need to call the users who request an order , I have followed the documentation and all the github repo with the code
Actually the code worked, and sended to me the sms to verify and all worked just fine !
Now, before release, I have just plugged another phone, requested the code to verify and the code never arrived !
I just tried in another phone with another number and also the verification code has never reached that phone either.
But I actually verified a phone number with the actual code and it works, so, why is the code not reaching my users phone ?
My use case needs this feature and if this is on Firebase side I will need to move to another service
Any suggestions ?
For testing you can use the verification code you added with the test phone number on the console.
Firebase Console Dashboard -> Authentication -> SignIn Method -> Phone -> Phone numbers for testing.
Sometimes, firebase don't need to send the otp for confirmation. it can automatically be done.
This method is called in two situations:
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. (This capability might be unavailable with some carriers.)
In either case, the user's phone number has been verified successfully, and you can use the PhoneAuthCredential object that's passed to the callback to sign in the user.
https://firebase.google.com/docs/auth/android/phone-auth#onverificationcompletedphoneauthcredential
Check out the docs for Firebase Phone Verification for Android : https://firebase.google.com/docs/auth/android/phone-auth?authuser=1#test-with-whitelisted-phone-numbers
Related
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.
I've implemented firebase phone authentication in my app and it's working fine when the user uses the app on the phone which the user receives the OTP on. I'm able to verify the OTP perfectly once I receive the OTP on my phone.
But, I just thought of another use case where a user might be using the app on the tablet and when he/she has to verify their mobile number in order to continue using the app. So they enter their mobile number on the tablet and receive the OTP on their phone. In this case, when they enter the OTP they received on their phone in the tablet, I'm not able to verify the OTP since the onVerificationCompleted() method holding null in place of the value.
Can anyone help handle this case gracefully?
Thank you.
In that case, you have to use the onCodeSent and onCodeAutoRetrievalTimeOut callbacks and ask the use to enter the code and initialize a PhoneAuthCredential to complete sign in.
I'm using firebase for phone number verification via sms.
This works nice when the verification is automatically done (SMS is sent and automatically app reads it and does the operations related to that the phone number has been verified).
But I'm now trying to make the verification with the code that is sent in this sms, as maybe not every user is going to be able to automatically read the sms message.
I thougt that the function PhoneAuthProvider.getInstance().verifyPhoneNumber would be overloaded with some option that would allow to send that code and perform the verification, but unless I'm missing something there doesn't seem to be a way with it.
On the other hamd I know this way of performing a verification via sent code, but it does require to sign in firebase, and I don't want that unless there's no another way, all that should happen is that the user sends its phone number along with the code and if correct, firebase sends something that is understood by the app as that the verification has been correct (no signing in anywhere).
Is there a way to do what I'm mentioning?
I have a similar problem with my new app released in Google Play Store. I just don't receive de sms code.
I mention that when I tested the app in debug mode and release mode it worked perfectly fine. The problem occurs when I download the app from Play Store.
Maybe you are right and the problem is that i didn't login user, because at this moment rules in Firebase Database are read and write == true.
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 !
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.