编辑firebase,swift项目中的信息 [英] Edit information in firebase, swift project
问题描述
如何在firebase中更新用户信息!
例如,他的电子邮件,密码和名称等。
我将使用什么firebase功能?
这是一个非常模糊的问题,有许多答案,但这里是基础。
假设你有这样的Firebase结构
用户
uid_0
user_name:Bill
电子邮件:bill@yipee.com
要将用户名从 leeeeroy:
var userNameRef = ref.childByAppendingPath(users / uid_0 / user_name)
userNameRef.setValue( Leeeeroy)
以上是一个小例子。您应该调查使用.updateChildValues。
Firebase网站有一个非常好的指导写数据,检查出来!
如果您正在调查实际的Firebase用户数据,而不是创建的用户节点,请查看
$ b $ (NSString *)密码toNewEmail:(NSString *)newEmail withCompletionBlock:(void(^)(NSError * error))block
这里是简单的swift代码来更改用户Firebase电子邮件
myRootRef.changeEmailForUser(bob@thing.com,密码:old_password,toNewEmail:new_password){(< #NSError!#>) - >
打印(完成!)
}
How Can I Update the user Information in firebase! For Example, his email, password, and name, etc.
What firebase function would I use?
That's a pretty vague question with numerous answers but here's the basics.
Assume you have a Firebase structure like this
users
uid_0
user_name: "Bill"
email: "bill@yipee.com"
To change the user name from Bill to Leeeeroy:
var userNameRef = ref.childByAppendingPath("users/uid_0/user_name")
userNameRef.setValue("Leeeeroy")
The above is a small example. You should investigate using .updateChildValues as well.
The Firebase website has a really good guide on writing data, check it out!
If you are looking into modifying the actual Firebase user data, instead of a users node you have created, look into
- (void)changeEmailForUser:(NSString *)email password:(NSString *)password toNewEmail:(NSString *)newEmail withCompletionBlock:(void ( ^ ) ( NSError *error ))block
here's the simple swift code to change the users Firebase email
myRootRef.changeEmailForUser("bob@thing.com", password: "old_password", toNewEmail: "new_password") { (<#NSError!#>) -> Void in
print("done!")
}
这篇关于编辑firebase,swift项目中的信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!