I have take a photo, then I update my current user photo to apply this change to the Firebase authenticated user.
What I spect is after updating this photo to the authenticated user, to get the photoUrl as a string like when I first sign in in my app
suspend fun updatePhoto(uri: Uri): Resource<Unit>{
val currentUser = FirebaseAuth.getInstance().currentUser
val profileUpdates = UserProfileChangeRequest.Builder().setPhotoUri(uri).build()
currentUser!!.updateProfile(profileUpdates).await()
currentUser.reload().await()
val userData = hashMapOf<String,Any>()
userData["photoUrl"] = currentUser.photoUrl.toString()
FirebaseFirestore
.getInstance()
.collection("user")
.document(currentUser.uid).set(userData, SetOptions.merge()).await()
return Resource.Success(Unit)
}
At this line userData["photoUrl"] = currentUser.photoUrl.toString() I expect the actual photoUrl updated in firebase and I'm getting a local Uri like file://my.com.app/cache/photo.jpg
If I updated the user photo from the authentication itself, does not firebase handle the updated photo and needs to return me the actual photo updated by that current user ?
I want to avoid using firebase storage to upload the photo and place it in my database, instead, I want to retrieve it directly from the updated user photo