ios - 无法在使用 Flutter 开发的 iOS 应用中使用 Firebase PhoneAuth 成功验证用户身份
问题描述
我正在使用 Firebase PhoneAuth 对用户进行身份验证。我已经按照网络上可靠来源的说明完成了所有集成。
我面临的错误是,我没有在 Firebase Auth 的 verifyPhoneNumber 方法中收到代码发送处理程序的回调。
这是使用的方法,一旦用户输入电话号码,就会调用 signInWithPhone(),然后调用 verifyPhoneNumber()。
Future<AuthUser> signInWithPhone(String phone) async {
await _firebaseAuth.verifyPhoneNumber(
phoneNumber: phone,
timeout: Duration(seconds: 60),
verificationCompleted: _phoneVerificationCompleted,
verificationFailed: _phoneVerificationFailed,
codeSent: _phoneCodeSent,
codeAutoRetrievalTimeout: _phoneCodeAutoRetrievalTimeout);
print("Phone Authentication Ended");
return null;
}
_phoneCodeSent(String verificationId, [int forceResendingToken]) async {
phoneVerificationId = verificationId;
}
这里应该在发送 otp 时调用 _phoneCodeSent()。在此方法中接收到的 verifyId 是身份验证所必需的。由于没有调用该函数,我没有收到验证 ID,但正在生成 otp。
任何帮助将不胜感激。
解决方案
请确保您已遵循这些 firebase 与 Flutter 集成的文档,
https:
//firebase.flutter.dev/docs/installation/ios
和 iOS 特定设置,根据此https://firebase.flutter.dev/docs/auth /phone#setup以及 4 个特定的处理程序。
推荐阅读
- php - 我想为显示的每个项目创建一个增量编号
- regex - 正则表达式匹配字符串#substring
- rocket-chip - 你能合成RSICV火箭芯片测试工具模块吗?
- rabbitmq - Masstransit:PublishFault context.Message 在无法访问代理时为空
- flutter - 如何在 Flutter 中使用 StreamBuilder 连接到等待状态
- reactjs - this.props.history.push 在 React-Router 中未定义
- reactjs - 反应输入 - 光标跳转到末尾
- manifest - 在 google-repo 清单中使用环境变量?
- configuration - 在本地初始化中包含全局 .ocamlinit
- html - Algolia - 如何在 menuSelect 下拉列表中自定义标签显示名称