Saya menggunakan kode berikut untuk memperbarui foto profil di Firebase:
func saveProfileImage(_ userUID: String, _ completion: @escaping (Error?) -> Void) {
let resizedImage = image.resized()
let imageData = UIImageJPEGRepresentation(resizedImage, 1.0)
ref = StorageReference.profileImages.reference().child(userUID)
downloadLink = ref.description
ref.put(imageData!, metadata: nil) {
(metaData, error) in
completion(error)
}
updateProfilePic(userUID)
}
updateProfilePic adalah fungsi yang dibuat untuk memicu childChanged sehingga pengguna mengunduh foto profil baru. Itu belum berfungsi dan menurut saya itu karena dipanggil sebelum StorageReference selesai diperbarui. Apakah ada cara untuk memastikan bahwa fungsi tersebut dipanggil hanya setelah Referensi selesai?