How to add custom profile details to the user in firebase? [duplicate]

耗尽温柔 提交于 2021-02-05 08:49:34

问题


How to add custom profile details to the user in firebase? I know we can already add displayName and photoURL, but I want to add more fields like age,sex, country etc. Is there any way to do that?

user.updateProfile({
      displayName: "Jane Q. User",
      photoURL: "https://example.com/jane-q-user/profile.jpg"
    }).then(function() {
      // Update successful.
    }).catch(function(error) {
      // An error happened.
    });

回答1:


You can create a users endpoint and store custom user data in there.

function writeUserData(userId, name, email, imageUrl) {
  firebase.database().ref('users/' + userId).set({
    username: name,
    email: email,
    profile_picture : imageUrl,
    // Add more stuff here
  });
}

See https://firebase.google.com/docs/database/web/read-and-write#basic_write for more info.



来源:https://stackoverflow.com/questions/49538158/how-to-add-custom-profile-details-to-the-user-in-firebase

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!