You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

咨询:Firebase Auth的verifyPhoneNumber函数是否有可用错误码列表?

Firebase Auth verifyPhoneNumber 错误码查找方案

你提到的verifyPhoneNumber函数在pub.dev的文档中确实没有单独列出错误码,但可以通过以下方式获取相关错误信息:

  • 捕获异常查看具体错误码:在调用该函数时,可在verificationFailed回调或全局catch块中捕获FirebaseAuthException,通过其code属性获取具体错误码,示例代码:
try {
  await FirebaseAuth.instance.verifyPhoneNumber(
    phoneNumber: '+1234567890',
    verificationCompleted: (PhoneAuthCredential credential) {},
    verificationFailed: (FirebaseAuthException e) {
      print('错误码:${e.code},错误信息:${e.message}');
    },
    codeSent: (String verificationId, int? resendToken) {},
    codeAutoRetrievalTimeout: (String verificationId) {},
  );
} catch (e) {
  if (e is FirebaseAuthException) {
    print('全局捕获错误码:${e.code}');
  }
}
  • 参考Firebase Auth通用错误码:该函数的大部分错误码和Firebase Auth其他方法的通用错误码一致,比如invalid-phone-number(无效手机号)、too-many-requests(请求过于频繁)、quota-exceeded(配额超限)等,这些错误码的含义可对应Firebase Auth核心错误说明来理解。

  • 查看原生平台文档:Flutter的Firebase Auth封装了原生SDK,Android和iOS平台的手机号验证相关错误码也可作为参考,比如Android的FirebaseAuthInvalidCredentialsException子类、iOS的FIRAuthErrorCode枚举中的相关项。

内容的提问来源于stack exchange,提问作者Advait

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.03 09:01:02