【问题标题】:Firebase Authentication updating user profile without permissionFirebase身份验证未经许可更新用户配置文件
【发布时间】:2021-07-31 22:44:30
【问题描述】:

用户可以在更新个人资料照片时从其设备的图库中选择一张照片。应用在用户选择照片之前请求权限。但问题是,当用户卸载该应用程序并再次安装时,他们将不再看到他们的个人资料照片,因为他们需要再次允许该权限。我使用此代码更新用户个人资料照片:

  override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)
    
    val userPhoto: CircleImageView = findViewById(R.id.userImage)

    if (requestCode == OPEN_GALLERY_REQUEST_CODE && resultCode == Activity.RESULT_OK) {
        val imageUri = data?.data
        userPhoto.setImageURI(imageUri)

        var user = Utils().getCurrentUser()
        val profileUpdates: UserProfileChangeRequest =
            UserProfileChangeRequest.Builder()
                .setPhotoUri(imageUri)
                .build()
        user?.updateProfile(profileUpdates)?.addOnCompleteListener { task ->
            if (task.isSuccessful) {
                Log.d("ProfileChange", "User profile updated.")
                Log.d("ProfileChange","${imageUri}")
            }
        }
    }
}

Logcat 输出为:D/ProfileChange: content://media/external/images/media/19344

是否有任何解决方案让用户在卸载并重新安装应用后无需接受任何权限即可查看其个人资料照片?

【问题讨论】:

  • READ_EXTERNAL_STORAGE 权限。
  • 所以你想接受一次,并在以后的应用安装中使用它,对吧?

标签: android firebase firebase-authentication firebase-storage android-permissions


【解决方案1】:

是否有任何解决方案让用户在卸载并重新安装应用后无需接受任何权限即可查看其个人资料照片。

很遗憾,您无法在应用卸载时保留权限。卸载应用程序后,与该应用程序相关的所有内容都会消失,包括本地缓存和权限。因此,您需要接受每次安装新应用的权限。

【讨论】:

  • 嘿阿卜杜勒萨梅特!我可以帮助您了解其他信息吗?如果您认为我的回答对您有所帮助,请考虑通过单击左侧投票箭头下方的复选标记(✔️)来接受它。应将颜色更改为绿色。我真的很感激。谢谢!
猜你喜欢
  • 2021-07-04
  • 1970-01-01
  • 2019-11-18
  • 1970-01-01
  • 2021-06-23
  • 2021-08-31
  • 2020-07-28
  • 2020-10-17
  • 1970-01-01
相关资源
最近更新 更多