gpt4 book ai didi

android - Firebase 客户端无权执行此操作

转载 作者:行者123 更新时间:2023-12-02 13:40:56 25 4
gpt4 key购买 nike

我在我的应用程序中使用 Firebase 身份验证,并且我有以下代码允许用户退出:

FirebaseAuth.getInstance().signOut()
userInfo.removeEventListener(listener)
val intent = Intent(this@SettingsFragment.context, LoginActivity::class.java)
intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TASK.or(Intent.FLAG_ACTIVITY_NEW_TASK)
startActivity(intent)
代码成功注销了用户,但我得到了这个说 The client does not have permission to perform this operation 的 toast .我为什么要吃这个 toast ?如何防止它发生?
更新 1: Firebase 实时数据库代码和事件监听器的移除
下面我包含了使用 Firebase 实时数据库的代码:
userInfo = database.getReference("users").child(auth.currentUser!!.uid)
listener = userInfo.addValueEventListener(object : ValueEventListener {
override fun onDataChange(dataSnapshot: DataSnapshot) {
for (postSnapshot in dataSnapshot.children) {
if (postSnapshot.key == "firstName") {
firstNamePreference.text = postSnapshot.getValue(String::class.java)
} else if (postSnapshot.key == "lastName") {
lastNamePreference.text = postSnapshot.getValue(String::class.java)
} else if (postSnapshot.key == "username") {
userNamePreference.title =
"Username: ${postSnapshot.getValue(String::class.java)}"
}
}
}

override fun onCancelled(databaseError: DatabaseError) {
Toast.makeText(
context, databaseError.message,
Toast.LENGTH_LONG
).show()
}
})
我还包括 userInfo.removeEventListener(listener)在我的注销代码中,但我仍然收到错误消息。
更新 2: Debug模式下的 Logcat 用于注销用户
D/InputTransport: Input channel destroyed: fd=77
D/ViewRootImpl@b3aa7b8[SettingsActivity]: MSG_WINDOW_FOCUS_CHANGED 0 1
D/InputMethodManager: prepareNavigationBarInfo() DecorView@6d11dc3[SettingsActivity]
D/InputMethodManager: getNavigationBarColor() -855310
W/ActivityThread: handleWindowVisibility: no activity for token android.os.BinderProxy@f47f5fd
W/SyncTree: Listen at /users/ezTJRHVKZXhHyMGQGGljdQpfzGv1 failed: DatabaseError: This client does not have permission to perform this operation
I/DecorView: createDecorCaptionView >> DecorView@aa5b516[], isFloating: false, isApplication: true, hasWindowDecorCaption: false, hasWindowControllerCallback: true
D/InputTransport: Input channel constructed: fd=78
D/ViewRootImpl@46f9f6b[LoginActivity]: setView = DecorView@aa5b516[LoginActivity] TM=true MM=false
D/ViewRootImpl@46f9f6b[LoginActivity]: dispatchAttachedToWindow
D/ViewRootImpl@46f9f6b[LoginActivity]: Relayout returned: old=[0,0][1440,2960] new=[0,0][1440,2960] result=0x7 surface={valid=true 480479002624} changed=true
D/OpenGLRenderer: eglCreateWindowSurface = 0x6fdfef7280, 0x6fdec7c010
D/ViewRootImpl@46f9f6b[LoginActivity]: MSG_RESIZED: frame=Rect(0, 0 - 1440, 2960) ci=Rect(0, 96 - 0, 192) vi=Rect(0, 96 - 0, 192) or=1
D/ViewRootImpl@46f9f6b[LoginActivity]: MSG_WINDOW_FOCUS_CHANGED 1 1
D/InputMethodManager: prepareNavigationBarInfo() DecorView@aa5b516[LoginActivity]
D/InputMethodManager: getNavigationBarColor() -855310
D/InputMethodManager: prepareNavigationBarInfo() DecorView@aa5b516[LoginActivity]
D/InputMethodManager: getNavigationBarColor() -855310
D/InputMethodManager: startInputInner - Id : 0
I/InputMethodManager: startInputInner - mService.startInputOrWindowGainedFocus
D/InputTransport: Input channel constructed: fd=89
D/InputTransport: Input channel destroyed: fd=97
D/FA: Connected to remote service
D/InputTransport: Input channel constructed: fd=92
D/ViewRootImpl@346cbca[Toast]: setView = android.widget.LinearLayout{75c95b1 V.E...... ......I. 0,0-0,0} TM=true MM=false
D/ViewRootImpl@346cbca[Toast]: dispatchAttachedToWindow
D/ViewRootImpl@346cbca[Toast]: Relayout returned: old=[0,96][1440,2768] new=[115,2282][1324,2512] result=0x7 surface={valid=true 480480571392} changed=true
D/OpenGLRenderer: eglCreateWindowSurface = 0x6fdf199d80, 0x6fdedfb010
D/ViewRootImpl@346cbca[Toast]: MSG_RESIZED: frame=Rect(115, 2282 - 1324, 2512) ci=Rect(0, 0 - 0, 0) vi=Rect(0, 0 - 0, 0) or=1
D/OpenGLRenderer: eglDestroySurface = 0x6fdfff3d00, 0x6fdfd7c000
D/ViewRootImpl@b3aa7b8[SettingsActivity]: Relayout returned: old=[0,0][1440,2960] new=[0,0][1440,2960] result=0x5 surface={valid=false 0} changed=true
D/ViewRootImpl@b3aa7b8[SettingsActivity]: setWindowStopped(true) old=false
D/ViewRootImpl@b3aa7b8[SettingsActivity]: Surface release. android.view.WindowManagerGlobal.setStoppedState:669 android.app.Activity.performStop:7647 android.app.ActivityThread.callActivityOnStop:4379 android.app.ActivityThread.performStopActivityInner:4357 android.app.ActivityThread.handleStopActivity:4432 android.app.servertransaction.TransactionExecutor.performLifecycleSequence:192 android.app.servertransaction.TransactionExecutor.cycleToPath:165 android.app.servertransaction.TransactionExecutor.executeLifecycleState:142
D/ViewRootImpl@b3aa7b8[SettingsActivity]: dispatchDetachedFromWindow
D/ViewRootImpl@b3aa7b8[SettingsActivity]: Surface release. android.view.ViewRootImpl.doDie:7967 android.view.ViewRootImpl.die:7935 android.view.WindowManagerGlobal.removeViewLocked:497 android.view.WindowManagerGlobal.removeView:435 android.view.WindowManagerImpl.removeViewImmediate:124 android.app.ActivityThread.handleDestroyActivity:4753 android.app.servertransaction.DestroyActivityItem.execute:39 android.app.servertransaction.TransactionExecutor.executeLifecycleState:145
D/InputTransport: Input channel destroyed: fd=91
D/OpenGLRenderer: eglDestroySurface = 0x6fdf199d80, 0x6fdedfb000
D/ViewRootImpl@346cbca[Toast]: dispatchDetachedFromWindow
D/ViewRootImpl@346cbca[Toast]: Surface release. android.view.ViewRootImpl.doDie:7967 android.view.ViewRootImpl.die:7935 android.view.WindowManagerGlobal.removeViewLocked:497 android.view.WindowManagerGlobal.removeView:435 android.view.WindowManagerImpl.removeViewImmediate:124 android.widget.Toast$TN.handleHide:1110 android.widget.Toast$TN$1.handleMessage:898 android.os.Handler.dispatchMessage:106
D/InputTransport: Input channel destroyed: fd=92

最佳答案

听起来您有一个 Firebase 数据库(实时数据库或 Cloud Firestore)的监听器,并且此监听器要求用户经过身份验证。当您将用户注销时,监听器变得无效,并被 Firebase 取消,并显示您看到的错误消息。
解决方案是在用户退出之前删除监听器。

关于android - Firebase 客户端无权执行此操作,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/63543161/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com