[英]How to increase the speed of Firebase authentication in flutter app
I have build an app which has login and register features.我已经构建了一个具有登录和注册功能的应用程序。 I also added signout feature and also when the user close and reopens the app firebase checks whether the user is logout or not, but the problem is when i open the app firebase taking lot of time atleast 8-10 second to check whether the user is already logged in or not, so how to increase the speed from firebase so that the user need not wait for 8-10 seconds for more.
我还添加了注销功能,并且当用户关闭并重新打开应用程序时 firebase 检查用户是否注销,但问题是当我打开应用程序 firebase 需要花费大量时间至少 8-10 秒来检查用户是否是否已经登录,那么如何从 firebase 提高速度,使用户无需等待 8-10 秒。
void initState() {
super.initState();
pageController = PageController();
// Detects when user signed in
googleSignIn.onCurrentUserChanged.listen((account) {
handleSignIn(account);
}, onError: (err) {
print('Error signing in: $err');
});
// Reauthenticate user when app is opened
googleSignIn.signInSilently(suppressErrors: false).then((account) {
handleSignIn(account);
}).catchError((err) {
print('Error signing in: $err');
});
}
handleSignIn(GoogleSignInAccount account) async {
if (account != null) {
await createUserInFirestore();
setState(() {
isAuth = true;
});
configurePushNotifications();
} else {
setState(() {
isAuth = false;
});
}
}
I am using this way to check wheater the user is login or not the app我正在使用这种方式来检查用户是否登录应用程序
Auth auth = Auth();
await auth.getCurrentUser().then((user) async {
runApp(MaterialApp(
theme: _themeData(),
home: user != null
? Home(
userId: user.uid
)
: Login(),
debugShowCheckedModeBanner: false,
routes: routes,
));
}).catchError((error) {
print("Here is ERROR $error");
});
}
It hardly takes one or two seconds to tell the user uid.告诉用户 uid 几乎不需要一两秒钟。 I hope it will resolve your issue.
我希望它能解决你的问题。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.