Firebase 身份验证匿名登录 [英] Firebase Auth Anonymous Login

查看:48
本文介绍了Firebase 身份验证匿名登录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用 Firebase Auth Anonymous Account 时,它偶尔会在系统中创建一个新的 UserID,有时它会使用相同的 UserID.我真的希望每次都能创建相同的 UserID,这样匿名用户仍然可以在应用程序中保持相同的进度/数据.这实际上是我开始使用 Firebase 的原因就是为了这个功能.即使在重新启动应用程序等之后,我如何始终保持匿名帐户以保持相同的用户 ID?

When using Firebase Auth Anonymous Account it occasionally creates a new UserID in the system and sometimes it uses the same UserID. I really want this to create the same UserID everytime so the anonymous user can still maintain the same progress/data in the app. This is actually the reason I started using Firebase was for this feature. How can I always maintain an anonymous account to keep the same UserID even after relaunching the app, etc.?

我希望用户每次以访客身份玩游戏时总是获得相同的 ID.我看到有些应用程序在卸载/重新安装后仍然存在.用户在什么情况下会获得新的 ID?

I want the user to always get the same ID everytime they play as a guest. There is apps that I have seen that even persist after uninstall/reinstall. What are the situations in which the user will get a new ID?

按照建议实施 firebase 身份验证后,除非我完全卸载应用程序并重新安装,否则它将保留匿名用户 ID.然后不再检测到匿名用户 ID,这意味着用户将不再拥有他们的访客游戏数据.此外,假设用户以访客身份登录并选择注销(即 auth.Signout()),那么他们也将无法再次访问其原始访客游戏数据.我是否仍然在这里遗漏了一些东西,或者 Firebase Auth 没有达到我的初衷?

After implementing firebase Auth as suggested it will maintain the Anonymous UserID unless I completely uninstall the app and reinstall. Then the Anonymous UserID is no longer detected which means the user will no longer have their Guest game data. Also, suppose the user is signed in as a guest and chooses to logout (ie. auth.Signout()) then they will also not be able to access their original Guest game data again. Am I still missing something here or does Firebase Auth not achieve my original intentions?

推荐答案

您可以使用 自定义身份验证系统.由于以访客身份播放"只会为特殊设备指定.您可以使用设备 ID 作为 CustomToken,然后调用 Firebase 身份验证方法:

You can use the Custom Auth System. Since the "Play as Guest" will only be specified for a special device. You can use Device ID as the CustomToken and then call Firebase Authentication Method:

auth.SignInWithCustomTokenAsync(custom_token).ContinueWith{.......

您可以提供custom_token"作为设备 ID.您可以通过以下方式获取设备 ID:

You can provide "custom_token" as the Device ID. You can get Device ID by:

string deviceID = SystemInfo.deviceUniqueIdentifier;

希望这有帮助...

这篇关于Firebase 身份验证匿名登录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆