gpt4 book ai didi

flutter - 在 Google Flutter 应用程序中管理社交用户详细信息

转载 作者:行者123 更新时间:2023-12-04 13:25:37 26 4
gpt4 key购买 nike

我是开发 Flutter 应用程序的初学者,并尝试创建一个用于教育目的的示例应用程序。最近几周我决定在 flutter 中做一个没有内置登录或注册部分的示例应用程序,因为它有像 Facebook 和谷歌这样的社交登录选项。我在网上搜索了很多关于如何在 Flutter 应用程序中实现 Facebook 和 Google 身份验证的代码示例。

我对这个社交登录实现有疑问,可能是因为缺乏移动应用程序架构级别的工作经验。在这一点上,我问自己一个问题“如何在应用程序中管理社交登录用户”

我有一个解决方案,例如如果用户可以成功登录,将用户详细信息存储到我们的(Firebase)数据库中检查用户电子邮件是否存在于数据库中,如果数据库中没有匹配的条目,它将在数据库中创建一个新用户,或者如果存在更新该特定用户的最后登录日期时间。因为这个应用程序以其他形式显示一些与用户相关的数据,它是在登录用户ID的基础上工作的,所以我需要将登录用户的详细信息存储在数据库中。

最佳答案

您提出的解决方案已经足够好了。返回的 ID 对于您的应用程序是唯一的。

使用返回到您的应用程序的 ID 作为您应用程序中用户的标识符。

查看此 answer唯一标识

刚离开social_login插件在这里

// Import package
import 'package:social_login/social_login.dart';

// Instantiate it
final socialLogin = SocialLogin();

//Before calling any methods, set the configuration
socialLogin.setConfig(SocialConfig(
facebookAppId: FACEBOOK_APP_ID,
googleWebClientId: GOOGLE_WEB_CLIENT_ID, /*In case a Google tokenId is needed*/
twitterConsumer: TWITTER_CONSUMER_KEY,
twitterSecret: TWITTER_CONSUMER_SECRET,
));

// Get current logged user
final FacebookUser facebookUser = await socialLogin.getCurrentFacebookUser();
final GoogleUser googleUser = await socialLogin.getCurrentGoogleUser();
final TwitterUser twitterUser = await socialLogin.getCurrentTwitterUser();

//Log in social networks
final FacebookUser facebookUser = await socialLogin.logInFacebookWithPermissions(FacebookPermissions.DEFAULT);
final GoogleUser googleUser = await socialLogin.logInGoogle();
final TwitterUser twitterUser = await socialLogin.logInTwitter();

//Log out from social networks
await socialLogin.logOutFacebook();
await socialLogin.logOutGoogle();
await socialLogin.logOutTwitter();

关于flutter - 在 Google Flutter 应用程序中管理社交用户详细信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58127601/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com