无法存储Firebase数据类型“ AuthService”没有成员“ setUserinformation”

时间:2018-10-08 19:15:12

标签: ios firebase-realtime-database swift4

我发现很难解决将数据存储到Firebase控制台的问题。我相信代码是正确的,但我似乎无法找出错误

类型“ AuthService”没有成员“ setUserinformation”

希望有人可以帮助我解决我的问题。非常感谢您的帮助!

我还附上了该问题的屏幕截图:screenshot of problem

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)
                }

              }

            )}

        )}
    }

1 个答案:

答案 0 :(得分:0)

您在静态方法( signUp )中调用了类方法( setUserInformation ),该方法不允许, self 对象也不允许在调用时创建。

您可以通过在 setUserInformation 方法中添加 static 或从 signUp 方法中删除 static 来解决此问题。