小编Mar*_*oso的帖子

Firebase 电话身份验证不发送带有代码的短信

我正在尝试使用 Firebase 为我的 Android 应用设置电话号码身份验证。我在 Firebase 控制台的“身份验证”选项卡上启用了电话身份验证,并添加了我的号码进行测试。我尝试了多个号码,但我没有收到任何短信,尽管控制台告诉我 PhoneCodeSent 功能已被触发并显示成功消息。我已经尝试修复它一段时间,但似乎无法找到可靠的答案。我的代码有什么问题?

我的代码如下

...
...
...
String verificationId;
int resendingToken;

Future<void> _sendConfirmationCode() async {
if (formKey.currentState.validate()) {
  formKey.currentState.save();

  final PhoneVerificationCompleted verificationCompleted = (FirebaseUser user) {
    setState(() {
      print('verification has been completed');
    });
  };

  final PhoneVerificationFailed verificationFailed = (AuthException authException) {
    setState(() {
      print(countrySelected);
      print(this.phone + "\n");
      print('verification failed error: ' + authException.message);}
    );
  };

  final PhoneCodeSent codeSent = (String verificationId, [int forceResendingToken]) async {
    this.verificationId = await verificationId;
    this.resendingToken = await forceResendingToken;
    print("code …
Run Code Online (Sandbox Code Playgroud)

android dart firebase firebase-authentication flutter

6
推荐指数
1
解决办法
1万
查看次数