当我更新firebase pod时出现波纹错误。
无法转换类型'的值(用户?,错误?) - > ()'到期望的参数类型'AuthDataResultCallback?' (又名'可选<(可选,可选) - >()>')
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)
})
})
}
我怎么能解决这个问题?
答案 0 :(得分:1)
只需编写没有类型定义的闭包。
更新代码:
Auth.auth().createUser(withEmail: email, password: password, completion: { user, error in
...
}
答案 1 :(得分:0)
尝试以下操作:
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)
})
})
}