繁体   English   中英

如何在React Native中更新配置文件(displayName)Firebase?

[英]How to update profile (displayName) firebase in React Native?

我在React Native中发现了更新配置文件Firebase的问题,我尝试举例,但全部失败,也许您可​​以给我建议或可以更正我的脚本。

firebase.auth().createUserWithEmailAndPassword(this.state.email, this.state.password)
    .then(
      (user)=>{
        if(user){
          user.updateProfile({
            displayName: 'Frank S. Andrew'
          }).then((s)=> {
            this.props.navigation.navigate('Account');
          })
        }
    })
    .catch(function(error) {
      alert(error.message);
    });

我尝试遵循所有示例,在警报中显示消息“ user.updateProfile不是函数”。

请任何人帮助我如何在React Native中更新配置文件(displayName)Firebase。

谢谢。

createUserWithEmailAndPassword方法返回一个UserCredential对象 这不是User本身,而是具有 user属性,它是User对象

因此,您需要什么:

firebase.auth().createUserWithEmailAndPassword(this.state.email, this.state.password)
    .then((userCredentials)=>{
        if(userCredentials.user){
          userCredentials.user.updateProfile({
            displayName: 'Frank S. Andrew'
          }).then((s)=> {
            this.props.navigation.navigate('Account');
          })
        }
    })
    .catch(function(error) {
      alert(error.message);
    });

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM