There is an error in the phone number verification of the released application.
On some devices (ios and android) the verification code is not sent and the verificationFailed runs.
We have not yet been able to reproduce the error and have not been able to confirm the error message, as many devices successfully authenticate.
Here is my code.
final FirebaseAuth _auth = FirebaseAuth.instance;
verifyPhoneNumber(context, String function) async {
loading = true;
try {
void verifiedCompleted(PhoneAuthCredential phoneAuthCredential) async {
await _auth.signInWithCredential(phoneAuthCredential);
Get.snackbar("認証に成功しました。", '');
initControllers();
loading = false;
}
void verifiedFailed(FirebaseAuthException authException) {
Get.snackbar('認証に失敗しました。', '入力を確認の上もう一度お試しください。');
print("AuthControllerError(verifyPhoneNumber):${authException.message}");
loading = false;
}
void smsCodeSent(String verificationId, [int? forceResendingToken]) {
Get.snackbar('認証コードを送信しました。', 'コードを確認し入力してください。');
_verificationId = verificationId;
smsCodeDialog(context, function);
loading = false;
}
void autoRetrieval(String verificationId) {
// Get.snackbar("タイムアウトしました", verificationId.toString());
_verificationId = verificationId;
loading = false;
}
await _auth.verifyPhoneNumber(
phoneNumber: "+81" + phoneNumberController.text.toString(),
timeout: Duration(seconds: 5),
verificationCompleted: verifiedCompleted,
verificationFailed: verifiedFailed,
codeSent: smsCodeSent,
codeAutoRetrievalTimeout: autoRetrieval,
);
} catch (e) {
loading = false;
print("AuthControllerError(verifyPhoneNumber):$e");
}
}
flutter doctor
[√] Flutter (Channel stable, 3.0.1, on Microsoft Windows [Version 10.0.19044.1826], locale ja-JP)
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.1.3)
[√] Android Studio (version 4.2)
[√] VS Code (version 1.70.0)
[√] Connected device (3 available)
[√] HTTP Host Availability
package version
firebase_core: ^1.19.2
firebase_auth: ^3.4.2
firebase_core_platform_interface: ^4.4.3
Sorry for my poor English.
Thank you.