我使用Firebase来处理我的用户注册和我的应用程序的登录。但是如果我登录,然后完全关闭我的应用程序,用户将被迫重新登录。我想让用户登录,除非他们点击“注销”
我的登录代码是:
        Auth.auth().signIn(withEmail: email, password: password, completion: {(user, error) in
            if let firebaseError = error {
                print(firebaseError.localizedDescription)
                return
            }
            self.presentTabBar()
        })
    }
}除非被特别告知注销,否则如何保持此用户登录?
发布于 2018-02-01 11:41:59
检查用户是否已登录:
if Auth.auth().currentUser != nil {
 // User is signed in.
 // ...
} else {
  // No user is signed in.
 // ...
}如果用户已登录,则转到Home ViewController。这样,当他再次打开应用程序时,他会去Home ViewController,除非他签了FIRAuth.auth().signOut()
有关更多信息,请查看以下内容:https://firebase.google.com/docs/auth/ios/manage-users
https://stackoverflow.com/questions/48561643
复制相似问题