【问题标题】:Firebase Phone Authorization Flutter WebFirebase 电话授权 Flutter Web
【发布时间】:2020-06-26 13:20:09
【问题描述】:

https://firebase.google.com/docs/auth/web/phone-auth

是否可以使用 Flutter 为 web 应用程序通过他们的电话号码授权用户,如果可以,如何?我在想你也许可以将 JS 包与 Dart 一起使用,但我有点卡住了。

我知道如何让 Firebase 手机身份验证适用于移动设备,但我很难让它与网络一起使用。

FirebaseAuth.instance.verifyPhoneNumber(
    phoneNumber: number,
    timeout: const Duration(seconds: 5),
    verificationCompleted: verificationCompleted,
    verificationFailed: verificationFailed,
    codeSent: codeSent,
    codeAutoRetrievalTimeout: codeAutoRetrievalTimeout);
 }

【问题讨论】:

  • 该调用需要发生以向用户发送验证码,如下所述: verifyPhoneNumber 但是“我似乎无法完全掌握”很难回答。代码有什么不清楚的地方?这就是需要调用的原因吗?这是论据之一吗?您越能具体说明您遇到的问题,我们就越有可能提供帮助。
  • 如果调用API没有报错,很有可能是短信正在发送。如果您没有在手机上收到它,那就是配送问题,我没有能力进行故障排除。但是这个话题经常出现:stackoverflow.com/…

标签: javascript firebase flutter web-applications firebase-authentication


【解决方案1】:

FlutterFire firebase_auth plugin 表示它适用于 Android、iOS 和 Web。所以应该可以。

有一个example of how to use the library,其中包含一个section on using Phone number verification to sign in

【讨论】:

  • 我认为它不适用于 Flutter Web,你应该看看this
【解决方案2】:

您可以使用 signInWithPhoneNumber 代替 verifyPhoneNumber 因为网络不支持 verifyPhoneNumber... 这是我向您发送我的代码以寻求帮助(注意:RecaptchaVerifier 在我的场景中是可选的,没有它就无法工作)

FirebaseAuth.instance.signInWithPhoneNumber(
    phone,
    RecaptchaVerifier(
      container: 'recaptcha',
      size: RecaptchaVerifierSize.compact,
      theme: RecaptchaVerifierTheme.dark,
    ));

如果您的代码仍然无法正常工作并且有任何疑问,请查看此flutter web phone Auth

【讨论】:

  • 嘿,感谢这个解决方案,我能知道如何验证 OTP 吗??
猜你喜欢
  • 2020-11-12
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-10
  • 1970-01-01
  • 1970-01-01
  • 2020-10-13
相关资源
最近更新 更多