Firebase OTP SMS has two codes, one for verification and another that's always the same for all users [duplicate] - flutter

Used Firebase Phone Auth in my Android app.
The sms contains extra characters ntEc9wgP0/J at the end of the template.
Tried setting FirebaseAuth.getInstance().setLanguageCode("en")
Template language is set to English in Firebase console.
What can be the reason behind this?
This is my sms code template in firebase console.
%LOGIN_CODE% is your verification code for %APP_NAME%.
Firebase Phone Auth itself is working absolutely fine. What am I missing here?
EDIT : image of problem
EDIT2 : how it should be

I also faced the same issue in my case auto retrieval hash was only coming when otp sms length was below 53 characters so i contacted firebase support team regarding this .
As per firebase support team "If this is Android traffic then this is the appended auto-retrieval hash. We use the SMS Retriever API . So this extra characters are expected because these are the auto-retrieval hash"
** To Increase the character length you can change your app name on the google console.

Related

Firebase sms auto fill not working after app published to play store

looking for some help with the auto-fill OTP function for my app while using Firebase authentication service. Auto fill functionality works fine in test app as sms has the hash code. But when I publish the app on Google Playstore, the hash code in the OTP authentication sms is replaced by the app name, and hence the sms auto fill stops working as it requires the hash code. Will be great if someone has come across this problem and can help with some solution or workaround.
What's is the workaround to this
I faced the same issue and mine was due to the app name too long to contain the hash-code. Below are few work around:
You need to make sure the message you receive contains the hash of your app. Below is the right format :
123456 is your verification code for %APP_NAME%.
xyz_hascode_123
If your SMS does not contain the hashCode at the end, you might have to shorten your app name to less than 16 characters.
If your app is already published on Google Play, the name in the SMS will be the same as the one in the GooglePlayStore.
If you changed the name to 15 characters and the error still persists, you might have to wait for at least 24hours for the change to reflect on Firebase.
If after all the above it's still not resolved, please check if your receiver is well configured in the code.
Check out the new GooglePlay policy on app names: Common app names violations

OTP [firebase_auth/unknown] null

I searched for days but couldn't find why am I getting this error.
E/FirebaseAuth(21984): [SmsRetrieverHelper] SMS verification code request failed: unknown status code: 17499 Error code:39
I/flutter (21984): [firebase_auth/unknown] null
i receive this exception when i use my country phone number(Sudan) but when i add another country phone number they receive the SMS verification code.
1.i enabled the Phone Sign-in method in my firebase console.
2.added SHA1 and SHA256 of google play console,signingReport and even key store in my firebase console and uploaded the new google services.json .
3.enabled the Android DeviceCheck API for my project in google cloud console.
4.enabled play integrity in app check.
any help!
thank you in advance.
It seems that there is no way around it, due to the sanctions exposed in Sudan firebase or in fact all google services will not work unless you use a VPN.
Try with sinch or twilio

Check existing data in firebase without be auth like in sign up step

I currently creating a flutter app with sign up feature and I want to avoid spamming account so I setted up a phone verification to send a code by sms and fill it into the app when signing up (through twilio api). But I want to check before sending the sms if the phone number is already registred in my firestore collection(auth == null). I heard about firebase rules but I don't really know how to build it to be security compliant. I tried to use linkWithCredential but didn't seem to work. If anyone would have any advices for me ?
Thank you :)
You can write a cloud function to check your database if the phone number exists and return the result to the client.
You can login anonymously in order to have an access to the firebase database.
Also, you can provide custom rules for each collection, so for example, your collection can have free access if you want, but don't do it, use anonymously login instead.

how to add the hash key to firebase OTP sms body section

we have checked the autofill functionality for android. so we needed the 11 char hash key to be added into the OTP SMS body. how to add that into firebase phone auth OTP message.
we referred to this documentation:
https://developers.google.com/identity/sms-retriever/overview
As of 2nd July 2021:
This is expected behavior - your application's name is long enough that it crowds out the application hash from the SMS.
Shortening the name of the app is the only fix for now
Read More
https://github.com/firebase/firebase-android-sdk/issues/2688#issuecomment-860940110

AWS Lambda & Cognito - Updating user phone number attribute without sending an SMS

I am working on an iOS app using Amazon Web Services and I am setting up a user data base using the Cognito Userpool. During the sign up process, if a user enters the wrong phone number by mistake and in result isn't receiving a verification code, I am trying to allow them to then enter a new phone number, and update their phone number user attribute. Right now I am using a Lambda function which uses the AdminUpdateUserAttribute function, which is then connected to a APIGateway which allows me to run it from XCode. The function itself works and it successfully updates the phone number attribute.
Problem
The problem that I am running into though, is that after the phone number attribute has been updated with the Lambda function, a verification code is automatically sent to the newly updated phone number via SMS. The verification code is weird though because when I use that code to confirm the user, it doesn't work. Meaning that code is invalid for confirmation purposes. But if I use the Resend Confirmation Code function it will then send a valid confirmation code to the newly updated phone number.
Question
So I guess the questions I have are:
How can I prevent the automatic SMS from sending after I update the user's phone number attribute?
Or, is there a way I can use the verification code that is automatically sent as a confirmation code?
Thank you in advanced.