3
votes

When I update firebase pods get this error:

Cannot convert value of type '(User?, Error?) -> ()' to expected argument type 'AuthDataResultCallback?' (aka 'Optional<(Optional, Optional) -> ()>')

static func signUp(username: String, email: String, User: String, Phone: String ,password: String, imageData: Data, onSuccess: @escaping () -> Void, onError:  @escaping (_ errorMessage: String?) -> Void) {
    Auth.auth().createUser(withEmail: email, password: password, completion: { (user: User?, error: Error?) in
        if error != nil {
            onError(error!.localizedDescription)
            return
        }

How can I fix this?

2
can you try Auth.auth().createUser(withEmail: email, password: password, completion: { user, error in ? - user9749232

2 Answers

2
votes

Just write closure without type definition.

Updated code:

Auth.auth().createUser(withEmail: email, password: password, completion: { user, error in
    ...
}
0
votes

Try the following:

static func signUp(username: String, email: String, User: String, Phone: String ,password: String, imageData: Data, onSuccess: @escaping () -> Void, onError:  @escaping (_ errorMessage: String?) -> Void) {
Auth.auth().createUser(withEmail: email, password: password, completion: { user, error in
        if error != nil {
            onError(error!.localizedDescription)
            return
        }
        let uid = user?.uid
        let storageRef = Storage.storage().reference(forURL: Config.STORAGE_ROOF_REF).child("profile_image").child(uid!)

        storageRef.putData(imageData, metadata: nil, completion: { (metadata, error) in
            if error != nil {
                return
            }
            let profileImageUrl = metadata?.downloadURL()?.absoluteString

             self.setUserInfomation(profileImageUrl: profileImageUrl!, username: username, Phone: Phone,email: email,User:User, uid: uid!, onSuccess: onSuccess)
        })
    })
}