简体   繁体   English

Flutter中如何允许用户创建和切换多个账户?

[英]How to allow user to create and switch between multiple accounts in Flutter?

I am trying to make a Flutter app where the user can sign in into multiple accounts (different email IDs) and can switch between them from the UserAccounsDrawerHeader .我正在尝试制作一个 Flutter 应用程序,用户可以在其中登录多个帐户(不同的 email ID)并可以从UserAccounsDrawerHeader在它们之间切换。 For example, in Gmail app, users can switch between multiple Gmail accounts.例如,在 Gmail 应用程序中,用户可以在多个 Gmail 帐户之间切换。 Is this possible using Firebase Auth for Flutter?这是否可以使用 Flutter 的 Firebase Auth?

In the default scenario, Firebase Auth generally does not support allowing a user to be signed in with multiple accounts at the same time.默认情况下,Firebase Auth 一般不支持用户同时登录多个账号。 If you want to add support, what you will have to do is use initailizeApp() to initialize a new App instance - one for each user account, and sign in the user to each one of them.如果您想添加支持,您需要做的是使用initializeApp()来初始化一个新的App实例 - 每个用户帐户一个,然后将用户登录到其中的每个帐户。 You will then have to pass that app instance around to the other Firebase APIs to use that account for authenticated access (for example, Firestore queries).然后,您必须将该应用程序实例传递给其他 Firebase API 以使用该帐户进行身份验证访问(例如,Firestore 查询)。

To be honest, it's not clear to me from the provided APIs how to do that last part.老实说,我从提供的 API 中不清楚如何完成最后一部分。 but perhaps Firestore.getInstance(app) might do it.但也许Firestore.getInstance(app)可能会这样做。

In any event, it is not trivial to implement.无论如何,实施起来并非易事。 There is not a simple configuration or trick that will allow multiple simultaneous sign-ins.没有允许多个同时登录的简单配置或技巧。 Usually apps just make the user sign out, then in again with another account.通常应用程序只是让用户退出,然后再次使用另一个帐户登录。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在 Firestore 和 Firebase Auth 中处理用户数据的最佳方式配置为允许每个电子邮件有多个帐户 - Best way to handle user data in Firestore and Firebase Auth configured to allow multiple accounts per email Flutter 应用内购买 - 如何根据登录的用户允许购买? - Flutter In app purchase - How allow purchase based on the user that is logged? 如何在Firebase中删除用户帐户? - How to delete user accounts in Firebase? 同时创建多个Firebase用户帐户 - Creating multiple Firebase user accounts at the same time 如何允许我的Unity应用程序在没有用户帐户且没有公共访问权限的情况下访问Firebase实时数据库? - How can I allow my Unity app access to a Firebase realtime Database without user accounts and without public access? 允许多个 Firebase 帐户使用相同的电子邮件地址是否安全? - Is it safe to allow multiple Firebase accounts with the same email address? 如何允许用户在 Firebase 数据库上创建和保存标记 - How to allow user to create and save marker on Firebase Database 如何仅允许特定用户在Firebase中创建新用户? - How to only allow a specific user to create new users in Firebase? 如何自动禁用firebase身份验证上的用户帐户? - How to disable user accounts on firebase authentication automatically? 如何直接从 Flutter 代码创建新的 Firestore 用户集合 - How to create a new Firestore user collection directly from Flutter code
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM