簡體   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