我发现很难解决将数据存储到Firebase控制台的问题。我相信代码是正确的,但我似乎无法找出错误
类型“ AuthService”没有成员“ setUserinformation”
希望有人可以帮助我解决我的问题。非常感谢您的帮助!
static func signUp(username: String, email: String, password: String, firstname: String, lastname: String, imageData: Data, onSuccess: @escaping () -> Void, onError: @escaping (_ errorMessage: String?) -> Void) {
Auth.auth().createUser(withEmail: email, password: password) { (authData: AuthDataResult?, error: Error?) in
if error != nil {
onError(error?.localizedDescription)
return
}
let uid = authData!.user.uid
let storageRef = Storage.storage().reference(forURL: Config.STORAGE_ROOF_REF).child("profile_image").child(uid)
storageRef.putData(imageData, metadata: nil, completion: { (_, error: Error?) in
if error != nil {
return
}
storageRef.downloadURL(completion: { (url: URL?, error: Error?) in
if let profileImageUrl = url?.absoluteString {
self.setUserInformation(profileImageUrl: profileImageUrl, username: username, email: email, firstname: firstname, lastname: lastname, uid: uid, onSuccess: onSuccess)
let ref = Database.database().reference()
let usersReference = ref.child("users")
let newUserReference = usersReference.child(uid)
newUserReference.setValue(["username": username,"firstname": firstname, "lastname": lastname,"email": email, "profileImageUrl": profileImageUrl])
onSuccess()
}
}
})
})
func setUserInformation(profileImageUrl: String, username: String, email: String, firstname: String, lastname: String, uid: String, onSuccess: @escaping () -> Void) {
let ref = Database.database().reference()
let usersReference = ref.child("users")
let newUserReference = usersReference.child(uid)
newUserReference.setValue(["username": username,"firstname": firstname, "lastname": lastname,"email": email, "profileImageUrl": profileImageUrl])
onSuccess()
}
}