退出时快照监听器权限错误-Kotlin / Firestore

时间:2020-11-02 04:20:58

标签: firebase kotlin google-cloud-firestore firebase-authentication

这是我第一次使用Firestore设置身份验证规则,我似乎无法弄清楚如何解决此问题。如果这是重复的话,我深表歉意,但是我找不到我想念的东西。注销我的应用程序时,即使出现错误,即使返回侦听器,我也会获得以下代码的“拒绝权限”。如何防止这种情况发生?

        db.collection("chats").whereEqualTo(currentUser, true)
            .addSnapshotListener {snapshot, error ->

                if (error != null) {
                    Log.e("ChatsFragment", "Error getting chats. Error: $error")
                    return@addSnapshotListener
                }

                if (snapshot!!.isEmpty) {
                    noMsgs.visibility = View.VISIBLE
                } else {
                    noMsgs.visibility = View.GONE
                }
            }

这是我的登出,以防万一。

    AuthUI.getInstance().signOut(this)
        .addOnCompleteListener { task ->
            if (task.isSuccessful) {
                val intent = Intent(this, CheckUser::class.java)
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
                finish()
                handler.postDelayed({
                    startActivity(intent)
                    Toast.makeText(this, "You have been logged out.", Toast.LENGTH_SHORT).show()
                }, 1000)
            } else {
                val intent = Intent(this, CheckUser::class.java)
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)
                finish()
                startActivity(intent)
                Log.e("LogoutActivity", "Error logging out. ${task.exception?.message.toString()}")
            }
        }

0 个答案:

没有答案