在 firebase 控制台中删除用户时直接通知应用程序?
notify application directly when you delete a user in the firebase console?
如果使用 firebase 控制台从 firebase 中删除用户,有没有办法直接通知应用程序?我尝试使用 authlistener,但是当我删除用户时,应用程序没有注意到当前用户的变化。我必须重新安装应用程序才能让应用程序注意到没有用户了?有办法解决吗?
我试过的
override fun getFirebaseAuthState() = callbackFlow {
val authStateListener = FirebaseAuth.AuthStateListener { auth ->
trySend(auth.currentUser == null)
}
auth.checkIfUserExists().addAuthStateListener(authStateListener)
awaitClose {
auth.checkIfUserExists().removeAuthStateListener(authStateListener)
}
}
调用它的 viewModel
init {
getAuthState()
}
fun getAuthState() = liveData{
useCases.getAuthState().collect{response ->
emit(response)
}
}
客户端的身份验证状态基于ID令牌,有效期为一小时,由SDK自动刷新。当您删除(或禁用)用户后,客户端将无法再刷新 ID 令牌,但其当前 ID 令牌的有效期最长为一个小时。
您可以强制客户端在此之前尝试刷新其令牌,但 Firebase 没有 built-in 方式立即通知客户端 (so-called out-of-band) 用户删除.
如果您想将用户的 ID 标记标记为无效,请查看有关 ID token revocation 的 Firebase 文档或以下问题之一:
- Firebase authentication not revoked when user deleted?
- Why firebase user still signed in after I deleted it from firebase dashboard
如果使用 firebase 控制台从 firebase 中删除用户,有没有办法直接通知应用程序?我尝试使用 authlistener,但是当我删除用户时,应用程序没有注意到当前用户的变化。我必须重新安装应用程序才能让应用程序注意到没有用户了?有办法解决吗?
我试过的
override fun getFirebaseAuthState() = callbackFlow {
val authStateListener = FirebaseAuth.AuthStateListener { auth ->
trySend(auth.currentUser == null)
}
auth.checkIfUserExists().addAuthStateListener(authStateListener)
awaitClose {
auth.checkIfUserExists().removeAuthStateListener(authStateListener)
}
}
调用它的 viewModel
init {
getAuthState()
}
fun getAuthState() = liveData{
useCases.getAuthState().collect{response ->
emit(response)
}
}
客户端的身份验证状态基于ID令牌,有效期为一小时,由SDK自动刷新。当您删除(或禁用)用户后,客户端将无法再刷新 ID 令牌,但其当前 ID 令牌的有效期最长为一个小时。
您可以强制客户端在此之前尝试刷新其令牌,但 Firebase 没有 built-in 方式立即通知客户端 (so-called out-of-band) 用户删除.
如果您想将用户的 ID 标记标记为无效,请查看有关 ID token revocation 的 Firebase 文档或以下问题之一:
- Firebase authentication not revoked when user deleted?
- Why firebase user still signed in after I deleted it from firebase dashboard