ios - How do I link each user to their data in Firebase for Swift 3? -
i have created project integrated firebase. has signup , login features. have personal information form fill individual users. when users different, data shown users. need show information related linked users. person should able access his/her database. couldn't find proper solution in swift 3.
from best can tell seems not referencing correct node in database. seeing of users data because variable messageref
pointed @ /users
. if you'd users see data need organize data when save messageitem
is @ /users/{user_id}
. access first getting user_id
, reading it's new location (/users/{user_id}
).
so i'd change these lines this:
override func viewdidload() { super.viewdidload() messageref = databaseref.child("users") // additional setup after loading view. }
to this:
override func viewdidload() { super.viewdidload() guard let user = auth.auth().currentuser else { return } messageref = databaseref.child("users/\(user.uid)") // additional setup after loading view. }
Comments
Post a Comment