I just updated my project to the latest version of Firebase Storage and I am now getting a warning: downloadURL() is deprecated: Use StorageReference.downloadURLWithComplet
I had the same problem, but I fixed it with this code:
uploadTask.observe(.success) { snapshot in
guard let imageURL = snapshot.metadata?.storageReference?.downloadURL(completion: { (url, error) in if error != nil {
print(error as Any)
} else { //add all you want
}
}) else { return }
let imageStr = String(describing: imageURL)
DBService.manager.updatePhoto(profileImageUrl: imageStr)
AuthService.manager.updatePhoto(urlString: imageStr)
}
}
Basically not using the metadata but instead just getting the url after the success of your observe event. Since it's successful and you know it's there, you can download the URL. It's there in their docs to 'Generate a download URL'. Below, I'm assuming your StorageReference is uploadProfilePicTask.
uploadProfilePicTask.downloadURL(completion: { (url, error) in
if (error == nil) {
if let downloadUrl = url {
// Make you download string
let downloadString = downloadUrl.absoluteString
}
} else {
// Do something if error
}
})