I’m having a problem with firebase phone authentication, yesterday I was testing login with phoneNumber but it didn’t work. I tested it with different devices, smsCode doesn’t send as to verify login. two weeks ago it was just working fine
I tried to upgrade all the packages including firebase_core and firebase_auth but nothing has changed.
firebase_core: ^2.4.0
cloud_firestore: ^4.2.0
firebase_auth: ^4.2.1
this is my code:
ElevatedButton(
onPressed: () {
if (otpVisibility) {
verifyOTP();
} else {
loginWithPhone();
}
},
child: Padding(
padding: EdgeInsets.symmetric(vertical: 1.h, horizontal: 1.h),
child: Text(
otpVisibility ? "verify" : "login",
style: TextStyle(fontSize: 15.sp, fontFamily: 'Cairo'),
),
),
),
this is the error I keep getting:
W/BpBinder( 2464): Slow Binder: BpBinder transact took 433ms, interface=com.google.android.gms.auth.api.phone.internal.ISmsRetrieverApiService, code=1 oneway=false
W/FirebaseAuth( 2464): [SmsRetrieverHelper] Timed out waiting for SMS.
void loginWithPhone() async {
auth.verifyPhoneNumber(
phoneNumber:_prefix + phoneController.text,
verificationCompleted: (PhoneAuthCredential credential) async {
await auth.signInWithCredential(credential).then((value) {
if (value.user != null) {
print("Done !!");
print("You are name saved successfully");
print("You are logged in successfully");
} else {
print("Failed!!");
}
}).catchError((e) {
Fluttertoast.showToast(msg: 'Something Went Wrong: ${e.toString()}');
});
},
verificationFailed: (FirebaseAuthException e) {
print(e.message);
},
codeSent: (String verificationId, int resendToken) {
otpVisibility = true;
verificationID = verificationId;
setState(() {});
},
codeAutoRetrievalTimeout: (String verificationId) {},
timeout: const Duration(seconds: 20),
);
}
void verifyOTP() async {
PhoneAuthCredential credential = PhoneAuthProvider.credential(
verificationId: verificationID, smsCode: otpController.text);
await auth.signInWithCredential(credential).then((value) {
print("You are logged in successfully");
uploadUserInfoToFirebase();
_nameSaver();
Fluttertoast.showToast(
msg: "You are logged in successfully",
toastLength: Toast.LENGTH_SHORT,
gravity: ToastGravity.CENTER,
timeInSecForIosWeb: 1,
backgroundColor: KInActiveColor,
textColor: Colors.white,
fontSize: 12.sp);
Navigator.push(
context, MaterialPageRoute(builder: (context) => HomePage()));
});
}
}
2
Answers
I had the same error, you are registering the same number, try deleting the number from Firebase/authentication/users or register a different number
enter image description here