【发布时间】:2018-09-14 09:38:53
【问题描述】:
我正在尝试使用 Firebase 电子邮件和密码登录方法为我的应用创建登录信息。当我尝试调用createUserWithEmailAndPassword 或signInWithEmailAndPassword 时,这些方法没有被调用。
如何验证 reactnative 中的 firebase 方法调用。
<Button onPress={this.onButtonPress.bind(this)}>Log In</Button>
onButtonPress(){
const { email, password } = this.state;
this.setState({error: ''});
console.log(email + ' ' + password); //==> this executes
firebase.auth().signInWithEmailAndPassword(email, password)
.then(function(){
console.log('sign insuccess'); //==> no execution
})
.catch(() => {
firebase.auth().createUserWithEmailAndPassword(email, password)
.then(function(){
console.log('create user success'); //==> no execution
})
.catch(() => {
this.setState({ error: 'Authentication Failed.' }); //==> no execution
});
});
console.log('buttonpress finished');
}
【问题讨论】:
-
您是否在 Firebase 控制台中启用了电子邮件方法?
-
你也完成了
Web Setup这一步吗? -
我已经添加了网络设置并启用了电子邮件和密码作为登录方法,但我仍然无法调用 firebase auth
-
@PeterHaddad 如何验证 firebase 本身是否已初始化我无法在 react native 中调用任何 firbase 方法。
标签: android reactjs firebase react-native firebase-authentication