我的问题如下: 我想保持用户登录状态,即使他关闭并杀死了颤抖的Web应用程序。 我正在使用Firebase进行身份验证。
在Firebase应用初始化之后,我尝试将持久性设置为“本地”,但这没有用。这样,如果我不杀死应用程序,它将保持记录状态。
//This is how my initialization looks like
...
@override
void initState() {
super.initState();
if(!fb.apps.isNotEmpty){
fb.initializeApp(
apiKey: myApiKey,
authDomain: myAuthDomain,
databaseURL: myDbURL,
storageBucket: myStorageBucket,
projectId: myProjID,
);
}
fb.auth().setPersistence('local');
}
...
//That's when I login the user with email and password
...
onPressed: () async {
var loggedUser = await auth.signInWithEmailAndPassword(email, password);
if(loggedUser != null){
Navigator.pop(context, loggedUser);
}else{
print(loggedUser);
}
}
...
你们有什么主意吗?