firebase - 如何在颤动中自动注销firebase用户?
问题描述
我正在开发一个以 firebase 作为后端和身份验证的颤振应用程序,
现在我希望该应用程序有一个试用版,用户可以在其中登录并使用具有完整功能的应用程序(大约一小时),然后退出在那一小时结束后自动。
到目前为止,我完成了以下工作:
1- 使用 google 帐户登录。
2-使用时间戳添加登录用户 _trial collection
。
Future enterTrial() async {
final UserCredential user = await Auth.instance.googleSignInMethod();
final User actualUser = user.user;
try {
//_trial is a collection for users in Trial Period
await _trial.doc(actualUser.email).set({.
"name": actualUser.displayName,
"email": actualUser.email,
"creationDate": FieldValue.serverTimestamp(),
});
} catch (e) {
print(e);
}
}
剩下的:
从登录一小时后,注销并将用户从 移动 _trial collection
到 _expired collection
.
这样我就可以检查用户是否已过期。
有没有办法在一段时间后自动注销?或定期比较creationTime 与currentTime 并相应地signOut?
提前致谢。
解决方案
是的,您可以通过使用background_fetch包来实现这一点,这为您提供了一个回调函数,您可以在该函数中调用您的注销方法。
推荐阅读
- node.js - 如何在 AWS Lambda 层中调试 ffmpeg-static
- python - 如何使用 C++ 以有效的方式生成随机数
- javascript - 反应钩子状态不使用最新
- python - 如何从 Jupyter Notebook 中的对象释放内存
- configuration - 如何更改 Visual Studio Code 快速修复语言?
- css - 使用 SVG 图标
- php - Laravel 数组验证无效值
- angular - Angular ul列表自我删除或更新数据并刷新
- python - 了解 Python 3.7 中类、namedtuple 和 __slots__ 的大小
- vba - Word 宏:在分节符后设置页面方向