如何在Flutter中将Firebase匿名用户迁移到经过身份验证的用户

时间:2019-08-23 14:09:13

标签: flutter firebase-authentication

在我的应用中,用户可以以访客用户身份登录。我想使用电子邮件和密码或Google对来宾用户进行身份验证。身份验证后,用户标识应保持不变。该怎么做?

1 个答案:

答案 0 :(得分:2)

要将匿名帐户升级为具有凭据的帐户,请使用您要使用的登录方法创建一个新帐户,然后按link the anonymous account and that new account together进行创建,如Firebase文档中所示。

因此,在Flutter中,您将使用相关的身份验证提供程序的getCredential方法(例如FacebookGoogle),然后在匿名用户对象上调用linkWithCredential