本文介绍了Firebase:如何获取User.uid?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用Firebaseauth来管理我的iOS应用程序的用户和数据.用户可以登录,并将他们的userinfo正确存储在数据库中.但是,当我尝试让用户使用以下字符串在不同的viewController中写入数据库时:
I'm using Firebaseauth to manage users and data for my iOS app. The users can log in, and their userinfo is stored correct in the database.But when I try to get the users to write to the database in a different viewController, using this string:
self.ref.child("users").child(user.uid).setValue(["username": username])
抛出的错误是
我想这很有道理,因为我还没有创建变量.但是我不知道该怎么声明?
That makes sense I guess, since I haven't created the variable. But I can't figure out how to declare it?
推荐答案
这是获取用户uid的方法:
This is how to get users uid:
let userID = Auth.auth().currentUser!.uid
这篇关于Firebase:如何获取User.uid?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!