如何在Firebase中向用户添加自定义配置文件详细信息? [英] How to add custom profile details to the user in firebase?
本文介绍了如何在Firebase中向用户添加自定义配置文件详细信息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何向Firebase中的用户添加自定义配置文件详细信息?我知道我们已经可以添加displayName和photoURL,但是我想添加更多字段,例如年龄,性别,国家等.有什么办法可以做到这一点?
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.
});
推荐答案
您可以创建 users
端点并将自定义用户数据存储在其中.
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
});
}
请参见 https://firebase.google.com/docs/database/web/read-and-write#basic_write 了解更多信息.
这篇关于如何在Firebase中向用户添加自定义配置文件详细信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文