【发布时间】:2025-12-20 05:50:06
【问题描述】:
我正在使用 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。
我们将不胜感激。
【问题讨论】:
-
"寻求调试帮助的问题('为什么这段代码不工作?')必须包括期望的行为、特定问题或错误和必要的最短代码 在问题本身。没有明确的问题陈述的问题对其他读者没有用处。请参阅:@ 987654321@"
-
嗨@FrankvanPuffelen 我已经为这个问题添加了更多细节。现在更清楚了吗?
标签: ios firebase flutter firebase-authentication