根据Firebase官方文档,我第一次使用Firebase电话身份验证,并且我发现验证码验证必须继续进行。尽管它起到了很好的作用,但是当它开始询问路标,桥梁等所有内容时,有时对于用户体验来说却变得非常糟糕。获取用户号码后,是否可以直接跳到验证码?根据文档,下面提到了代码。谢谢。
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?)
// ...
});
答案 0 :(得分:2)
您无法使用默认身份验证删除验证码验证。
使用anonymous authentication避免出现captcha
个字母。同样,anonymous authentication
比Firebase Authentication默认身份验证更简单。
用法:
firebase.auth().signInAnonymously().catch(function(error) {
// Handle Errors here.
var errorCode = error.code;
var errorMessage = error.message;
// ...
});
有关详细信息,请遵循以下官方文档:https://firebase.google.com/docs/auth/web/anonymous-auth
答案 1 :(得分:2)
在集成iOS SDK时,我遇到了同样的问题。
如果google具有跨语言的Firebase SDK相同的体系结构和类,则该解决方案可能适用于您。
Auth.auth().settings?.isAppVerificationDisabledForTesting = true
答案 2 :(得分:1)
使用大小:“正常”至大小:“不可见”
window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier(
"recaptcha-container",
{
size: "invisible",
callback: function(response) {
submitPhoneNumberAuth();
}
}
);
答案 3 :(得分:1)
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();
}
}
);
答案 4 :(得分:1)
方法一:
firebase.auth().settings.appVerificationDisabledForTesting = true;
Firebase 文档
https://firebase.google.com/docs/auth/web/phone-auth?authuser=0#web-v8_6
// Turn off phone auth app verification.
firebase.auth().settings.appVerificationDisabledForTesting = true;
var phoneNumber = "+16505554567";
var testVerificationCode = "123456";
// This will render a fake reCAPTCHA as appVerificationDisabledForTesting is true.
// This will resolve after rendering without app verification.
var appVerifier = new firebase.auth.RecaptchaVerifier('recaptcha-container');
// signInWithPhoneNumber will call appVerifier.verify() which will resolve with a fake
// reCAPTCHA response.
firebase.auth().signInWithPhoneNumber(phoneNumber, appVerifier)
.then(function (confirmationResult) {
// confirmationResult can resolve with the fictional testVerificationCode above.
return confirmationResult.confirm(testVerificationCode)
}).catch(function (error) {
// Error; SMS not sent
// ...
});
方法二:
https://firebase.google.com/docs/auth/web/phone-auth#use-invisible-recaptcha
window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('sign-in-button', {
'size': 'invisible',
'callback': (response) => {
// reCAPTCHA solved, allow signInWithPhoneNumber.
onSignInSubmit();
}
});
答案 5 :(得分:0)
Firebase为验证码大小提供了两个属性
<%= link_to "Notify link path", notify.link_path(notification_id: notify.id) do %>
有关更多详细信息,请参阅此Official链接
答案 6 :(得分:0)
实际上你不能。但是,某些设备它不起作用。相反,设置安全并启用 API 密钥。然后回到您在 Firebase 中的项目设置,如果它不存在,则将 SHA-25 从 Android Gradle 复制并粘贴到那里。通过这种方式,在应用浏览器中重定向将不再对您造成刺激...
答案 7 :(得分:0)
转到Firebase 控制台--> 到您的项目--> 项目概览设置--> 项目设置--> 应用检查--> 概览(为SafetyNet 注册您的应用)。 >
然后您的应用将停止重定向到网络以进行验证码验证