reactjs - Firebase - 电话号码验证
问题描述
所以我正在构建一个简单的应用程序,我想要电话号码身份验证。但是,按照网站上的说明进行操作后,似乎没有任何反应。
// App.js
handleNext = () => {
verifyPhoneNumber(this.state.phoneNumber);
this.setState(prevState => ({
activeStep: prevState.activeStep + 1
}));
};
...
<Button
size="small"
onClick={this.handleNext}
disabled={activeStep === maxSteps - 1}
id={"verify-phone-number-button"}
>
Next
</Button>
//Controller.js
export const verifyPhoneNumber = (phoneNumber) => {
console.log(phoneNumber) // +14084445555
firebase.auth().useDeviceLanguage();
window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('verify-phone-number-button', {
'size': 'invisible',
'callback': function (response) {
// reCAPTCHA solved, allow signInWithPhoneNumber.
console.log("reCAPTCHA solved")
var appVerifier = window.recaptchaVerifier;
firebaseApp.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;
console.log("success")
}).catch(function (error) {
console.log(error)
// Error; SMS not sent
// ...
});
}
});
}
reCAPTCHA solved
永远不会被打印意味着它永远不会在那里。但是,它也没有打印任何错误消息,所以我不确定发生了什么。
谢谢你的帮助!
解决方案
推荐阅读
- python - 如何设置 ttk 主题并为 OptionMenu 设置默认值?
- wordpress - 我正在使用 woo-commerce 创建一个图书销售网站。我想使用本书作者的名字。我怎样才能做到这一点?
- nativescript - NativeScript StackLayout 问题 - 如何将百分比设置为宽度和高度?
- javascript - 获取页面 url,从 URL 中删除字符串,使用新 url 嵌入 src
- python-3.x - 什么是子类化 python 的列表或 UserList 的好方法,以便我可以更改基础数据但使用内置排序?
- python - sh 1 语法错误(尝试运行外部 python 脚本时出现意外
- powerbi - 频率计数器
- c++ - 在大型容器中搜索相应的结构
- python - 如何在 Intellij 中创建一个在缩写中带有变量名的实时模板?
- list - 查找所有可能的 X 列表