【发布时间】:2021-05-21 12:22:00
【问题描述】:
问题:输入电话号码以接收验证码时出现以下错误:Error FirebaseAuth [SmsRetrieverHelper] SMS verification code request failed: unknown status code: 17042 Invalid format。我输入的号码是+1xxxxxxxxxx。
我最终希望能够做的是接收验证码并验证以允许用户重新进入游戏。
下面的代码是我用来发送短信验证码和验证的:
void SMSVerification(string phone, bool consent_sent)
{
if (consent_sent == true)
{
///Application.OpenURL("sms:" + sms);
var phoneAuthProvider = Firebase.Auth.PhoneAuthProvider.GetInstance(auth);
phoneAuthProvider.VerifyPhoneNumber(phone, phoneAuthTimeoutMs, null,
verificationCompleted: (cred) =>
{
if (signInAndFetchProfile)
{
auth.SignInAndRetrieveDataWithCredentialAsync(cred).ContinueWith(HandleSignInWithSignInResult);
Debug.Log("SignInAndRetrieveDataWithCredentialAsync");
}
else
{
auth.SignInWithCredentialAsync(cred).ContinueWith(HandleSignInWithUser);
Debug.Log("SignInWithCredentialAsync");
}
},
verificationFailed: (error) =>
{
Debug.Log("Verification Failed");
},
codeSent: (id, token) =>
{
phoneAuthVerificationId = id;
Debug.Log("Codesent successful");
},
codeAutoRetrievalTimeOut: (id) =>
{
Debug.Log("CodeTiemOut");
});
}
}
public void VerifyReceivedPhoneCode()
{
var phoneAuthProvider = Firebase.Auth.PhoneAuthProvider.GetInstance(auth);
// receivedCode should have been input by the user.
//string code = verificationcodeInputField.text.ToString();
string code = "Place Holder";
Debug.Log("The Code for verification is" + code);
var cred = phoneAuthProvider.GetCredential(phoneAuthVerificationId, code);
if (signInAndFetchProfile)
{
auth.SignInAndRetrieveDataWithCredentialAsync(cred).ContinueWith(
HandleSignInWithSignInResult);
}
else
{
auth.SignInWithCredentialAsync(cred).ContinueWith(HandleSignInWithUser);
}
}
任何帮助将不胜感激。
【问题讨论】:
-
请记住让您的问题标题成为您问题的摘要,而不是一系列标签。我已经为你编辑了。
-
我查看了文档,您使用的是
+1 650-555-3434格式还是使用+1650-555-3434格式,这似乎相当具体。 (注意:这些不是真实的电话号码,来自谷歌的例子。 -
@DekuDesu:你能把它发给我的文档中的什么地方吗?
-
这适用于 Android,但我认为 API 非常相似,它是 here under
Test With Fictional Phone Numbers它提到了长度和格式要求,它们提供了一个与您所说的不同的示例。 -
@DekuDesu:谢谢。我会尝试格式化数字
标签: c# unity3d firebase-realtime-database