[英]How to use the same firebase anonymous user in a flutter app
I'm currently developing a Flutter app for in a internal project whose process is :我目前正在为一个内部项目开发一个 Flutter 应用程序,其过程是:
By doing so, each time an AU log himself, he can validate and then switch back to anonymous mode.通过这样做,每次 AU 自己登录时,他都可以验证然后切换回匿名模式。 The problem is that Firebase creates a new anonymous user each time.
问题是 Firebase 每次都会创建一个新的匿名用户。
The app could be utilized on multiple devices across the company, which could create 100's of anonymous users a day, while in fact it was only 6-7 users, so what can I do to avoid this ?该应用程序可以在整个公司的多个设备上使用,每天可以创建 100 名匿名用户,而实际上只有 6-7 个用户,那么我该怎么做才能避免这种情况呢?
I've read about customIdToken but I haven't come to a solution for my problem.我已经阅读了 customIdToken 但我还没有找到解决我的问题的方法。
Here is the code I'm using:这是我正在使用的代码:
Future<FirebaseUser> signInAnonToken(String token) async {
FirebaseUser user = await _firebaseAuth.signInWithCustomToken(token: token);
return user;
}
FirebaseUser userAnon = await widget.auth.signInAnonToken("useranonuid");
Where "useranonuid" is the uid of the anonymous user but also the token I get by using the getIdToken(refresh:true)
method其中“useranonuid”是匿名用户的 uid,也是我使用
getIdToken(refresh:true)
方法获得的令牌
Thanks in advance.提前致谢。
The problem is that Firebase creates a new anonymous user each time.
问题是 Firebase 每次都会创建一个新的匿名用户。
The workaround that I did on my end is to add deleting the anonymous user on the end of each workflow.我最后做的解决方法是在每个工作流的末尾添加删除匿名用户。 This should prevent the Firebase project hitting the 100 million anonymous user account limit .
这应该可以防止 Firebase 项目达到1 亿匿名用户帐户的限制。
There's no way to restore previous Firebase Anonymous Auth instance.无法恢复之前的 Firebase Anonymous Auth 实例。 That would defeat the purpose of being "anonymous" in the first place.
这首先会破坏“匿名”的目的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.