如何使用javascript从Firebase phone auth中删除验证码验证?
我是第一次使用firebase phone auth,根据firebase官方文档,验证码验证必须继续进行。虽然它有很好的用途,但有时当它开始询问路标、桥梁等信息时,会对用户体验造成很大影响。有没有一种方法可以在获得用户号码后直接跳到验证码?根据文档,代码如下所述。谢谢如何使用javascript从Firebase phone auth中删除验证码验证?,javascript,firebase,firebase-authentication,Javascript,Firebase,Firebase Authentication,我是第一次使用firebase phone auth,根据firebase官方文档,验证码验证必须继续进行。虽然它有很好的用途,但有时当它开始询问路标、桥梁等信息时,会对用户体验造成很大影响。有没有一种方法可以在获得用户号码后直接跳到验证码?根据文档,代码如下所述。谢谢 var phoneNumber = getPhoneNumberFromUserInput(); var appVerifier = window.recaptchaVerifier; firebase.auth().signI
var phoneNumber = getPhoneNumberFromUserInput();
var appVerifier = window.recaptchaVerifier;
firebase.auth().signInWithPhoneNumber(phoneNumber, appVerifier)
.then(function (confirmationResult) {
// SMS sent. Prompt user to type the code from the message, then sign the
// user in with confirmationResult.confirm(code).
window.confirmationResult = confirmationResult;
}).catch(function (error) {
// Error; SMS not sent
// ...
});
var code = getCodeFromUserInput();
confirmationResult.confirm(code).then(function (result) {
// User signed in successfully.
var user = result.user;
// ...
}).catch(function (error) {
// User couldn't sign in (bad verification code?)
// ...
});
在身份验证设置中使用
isAppVerificationDisabledForTesting=TRUE
,如下给定代码段所示:
Auth.auth().settings.isAppVerificationDisabledForTesting = TRUE
有关详细信息,请查看以下官方信息:
JavaScript-
SDK参考-我在集成iOS SDK时遇到了相同的问题 若google跨语言拥有相同的firebase SDK体系结构和类,这个解决方案可能适合您
Auth.auth().settings?.isAppVerificationDisabledForTesting = true
使用大小:“正常”到大小:“不可见”
Firebase为验证码大小提供了两个属性
window.recaptchaVerifier=new firebase.auth.recaptchaVerifier(
“recaptcha容器”{
尺寸:“不可见”
}
);
有关更多详细信息,请参阅此链接,实际上您不能。但是,有些设备不工作。相反,请设置安全设置并启用API密钥。然后返回Firebase中的项目设置,如果不存在SHA-25,则将其从Android Gradle复制并粘贴到那里。通过这种方式,应用程序内浏览器重定向将不再让您感到恼火…有什么解决方案吗?谢谢!对于web SDK:从“firebase/app”导入firebase;firebase.auth().settings.appVerificationDisabled=trueappVerificationDisabledForTesting=trueappVerificationDisabledForTesting=trueAs标签,用于测试。对于你的应用来说,这不是一个长期的解决方案。实际上,你需要将你正在使用的电话号码列入白名单。它只是让安全网谷歌云ref到Invisible的迭代测试快速出现,取代了整个屏幕;例如,如果您连接到VPN并重新加载此窗口,则可能会触发它。
window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier(
"recaptcha-container",
{
size: "invisible",
callback: function(response) {
submitPhoneNumberAuth();
}
}
);
firebase.initializeApp(firebaseConfig);
// Create a Recaptcha verifier instance globally
// Calls submitPhoneNumberAuth() when the captcha is verified
window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier(
"recaptcha-container",
{
size: "invisible",
callback: function(response) {
submitPhoneNumberAuth();
}
}
);