简体   繁体   中英

Firebase Phone Authentication operates with Limits to 5 OTP SMS only- Mobile App in Flutter

Need Help from Firebase community !!

We have implemented Firebase Authentication using Phone provider in Flutter.

Below Plugin configured in pubsec.yaml

firebase_core: ^1.3.0 firebase_auth: ^1.4.1

await FirebaseAuth.instance.verifyPhoneNumber(
phoneNumber: phoneNumberText,
verificationCompleted: (PhoneAuthCredential authCredential) =>
_verificationComplete(
context, authCredential, phoneNum,
updateWrongPhoneUI: updateWrongPhoneUIWidget,
duplicateUser: duplicateUserhandler),
verificationFailed: (FirebaseAuthException exception) =>
_verificationFailed(exception,
updateWrongPhoneUI: updateWrongPhoneUI), //After 5 attempts - we are getting response as too-many-requests
codeSent: (String verificationIdLocal, int resendTokenLocal) => _codeSent(
verificationIdLocal, resendTokenLocal,
updateWrongPhoneUI: updateWrongPhoneUI),
** //in this callback we are re-directing to input screen get OTP**
codeAutoRetrievalTimeout: (String verificationId) {
print('FirebaseAuth ' 'Code auto retrieval Timedout');
},
);

Problem : After attempts of Phone authentication on same Phone number for 5 times, the SMS (OTP) stops flowing.

We are running on SPARK pricing plan.

The messages are throttled if sent to the same phone number multiple times within a period of time.

So you can do either of the following:

  • use a different phone number for testing or
  • wait for some time to pass before trying again

Here's a quote from the documentation :

To prevent abuse, Firebase enforces a limit on the number of SMS messages that can be sent to a single phone number within a period of time. If you exceed this limit, phone number verification requests might be throttled. If you encounter this issue during development, use a different phone number for testing, or try the request again later.

according to their support team the limit is 5 sms per 4 hours.

Now you can able to add upto 10 fictional(test) phone numbers.

Means you can able to use these phone numbers for testing purpose

  1. without consuming your usage quota.
  2. without sending an actual SMS.(its works like a user_name password for testing).

now go here And enable Identity Platform and click providers then click the edit button on the phone Auth

Then a screen will show up, In that add your testing phone number(ex +919876543210) and your own OTP (ex 123456 )

Note: before adding your mobile number for testing make sure to remove your mobile number in the existing authentication tab other wise it won't work

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM