问题
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