Firebase身份验证不会持续登录用户,每次刷新或重新打开应用程序时我都必须重新登录.
我已经尝试将持久性设置为本地,并且回调确实验证了它的设置,但持久性仍然无效
为了设置持久性我正在使用…
//set auth persistence firebase.auth().setPersistence(firebase.auth.Auth.Persistence.LOCAL) .then(function() { console.log("successfully set the persistence"); }) .catch(function(error){ console.log("Failed to ser persistence: " + error.message) });
firebase.auth().signInWithEmailAndPassword(email,password) .then((user) =>{ this.checkAccountStatus(user.uid,user.email); }) .catch(function(error) { // Handle Errors here. var errorCode = error.code; var errorMessage = error.message; console.log(errorMessage) // ... });
if (firebase.auth().currentUser) { const currentUser = firebase.auth().currentUser; console.log("Signed in username" + currentUser.displayName); this.props.navigation.navigate('AppTab'); }else{ console.log("no user signed in"); this.props.navigation.navigate('AuthTab'); }
如果有什么我做得不对