我想添加一个属性到Firebase用户对象.
user documentation表示,我只能使用Firebase实时数据库存储其他属性.
我不确定这在实践中如何运作.
以下是什么意思在实践中?
You cannot add other properties to the Firebase User object directly;
instead,you can store the additional properties in your Firebase
Realtime Database.
我解释如下:
“您不能修改FIRUser对象的属性,但您可以将其与其他对象组合”
我找到了这样我设置的设置功能documentation:
var userRef = ref.child("users"); userRef.set({ newfield: "value" });
这是一个明智的做法吗?
解决方法
你几乎在那里在传统Firebase文档中,我们在
storing such additional user data上有一节.
关键是在用户的uid下存储附加信息:
let newUser = [ "provider": authData.provider,"displayName": authData.providerData["displayName"] as? Nsstring as? String ] // Create a child path with a key set to the uid underneath the "users" node // This creates a URL path like the following: // - https://<YOUR-FIREBASE-APP>.firebaseio.com/users/<uid> ref.childByAppendingPath("users") .childByAppendingPath(authData.uid).setValue(newUser)
原文地址:https://www.jb51.cc/mssql/82264.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。