do you have problem like me I have an application using Phone Authentication with Firebse. At first I test with my simulator on my development it work normally but after I build the apk to test on my phone I always got "We have blocked all requests from this device due to unusual activity. Try again later." no matter I change to other number or I even change to another device yet it show the same error message.
Future<void> phoneAuthentication (String phoneNumber) async {
verificationCompleted(PhoneAuthCredential credential) async {
await _auth.signInWithCredential(credential);
print("TEST_LOG============verificationCompleted=========>");
showSnackBar("Authentication Successful");
}
verificationFailed(FirebaseAuthException e) {
print("TEST_LOG========failure=============>${e.message}");
showSnackBar("Authentication Failed: ${e.message}");
}
codeSent(String verificationId, int? resendToken) {
print("TEST_LOG===========Code shared==========>${verificationId}");
Navigator.push(
context,
MaterialPageRoute(builder: (context) => MyVerify(
verificationId: verificationId,
login: _loginController.text,
email: _emailController.text,
password: _passwordController.text,
phoneNumber: _phoneNumberController.text,
)
),
);
}
codeAutoRetrievalTimeout(String verificationId) {
print('TEST_LOG===========Time out==========>${verificationId}');
}
showDialog(
context: context,
barrierDismissible: false,
builder: (BuildContext context) {
return Center(
child: CircularProgressIndicator(), // Display CircularProgressIndicator
);
},
);
showSnackBar('Verifying...');
await FirebaseAuth.instance.verifyPhoneNumber(
phoneNumber: phoneNumber,
timeout: const Duration(seconds: 60),
verificationCompleted: verificationCompleted,
verificationFailed: verificationFailed,
codeSent: codeSent,
codeAutoRetrievalTimeout: codeAutoRetrievalTimeout,
);
Navigator.pop(context);
}
2
Answers
There’s a limit of 5 SMS per phone number per 4 hours.
So when you are testing you need to add your phone number at "Phone Numbers for testing" along with a verification code of your choice.
You should also delete that user.
Go to your Firebase console -> Auth -> Users
Locate the user you are testing.
Delete this user.
You have tried to fetch sms from single number multiple times, try to change the number or try with different device.