我已经建立了一个具有登录和注册功能的应用程序。我还添加了注销功能,也当用户关闭并重新打开应用程序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;
});
}
}发布于 2019-11-04 20:46:14
我正在使用这种方法来检查用户是否登录了应用程序
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");
});
}告诉用户uid几乎不需要一到两秒钟。我希望它能解决你的问题。
https://stackoverflow.com/questions/58693010
复制相似问题