我是React native的新手。今天,我想创建一个链接到firebase的登录和注册页面。我遵循了本教程-https://www.youtube.com/watch?v=TkuQAjnaSbM&t=110s-逐字逐句,发现它非常成功。
我在iOS手机上安装了expo应用程序,然后从那里获得了构建版本。我们和视频教程之间的唯一区别是,它使用了一个android模拟器,并且我在真实手机上的expo应用程序上进行构建。但是问题是我无法通过脚本将新用户添加到Firebase。我也分享代码。如果您有帮助,我将不胜感激。
handleSignUp=() => {
firebase
.auth()
.createUserWithEmailAndPassword(this.state.email, this.state.password)
.then(userCredentinals => {
return userCredentinals.user.updateProfile({
displayName: this.state.name
});
})
.catch(error => this.setState({ errorMessage: error.messsage}));
};
以某种方式我无法与Firebase连接。但我确定我将配置代码块放在正确的位置。也许我无权将自己的手机写入用作模拟器的数据库中?
<TouchableOpacity style={styles.button}>
<Text style={{color:"#FFF", fontWeight: "500"}}
onPress={this.handleSignUp}
onPress={() => this.props.navigation.navigate("Home")}
>Kayıt Ol</Text>
</TouchableOpacity>
请这样更新您的功能。
const handleSignUp = () => {
console.log('Function is called');
firebase
.auth()
.createUserWithEmailAndPassword(this.state.email, this.state.password)
.then(userCredentinals => {
console.log('Success');
return userCredentinals.user.updateProfile({
displayName: this.state.name
});
})
.catch(error => {
console.log(error);
this.setState({ errorMessage: error.messsage});
});
};
然后请使用console
中显示的内容来更新您的问题。然后,我将可以帮助您解决这个问题。