在我的新项目中,我使用以下代码确保用户不必每次打开应用程序时都转到登录屏幕:
// this means that there is a user logged in... take them to the main view.
if let x = FIRAuth.auth()?.currentUser?.uid {
print("The current user is: \(x)")
// first param is storyboard name
self.setTheRootViewController("Main", identifier: "GroupChatsView")
}
// take them to the login view controller
else {
self.setTheRootViewController("Main", identifier: "LoginView")
}
我还没有创建任何用户,所以我希望这段代码每次都能带我进入登录 View 。但是,出于某种奇怪的原因,当我打印出当前用户的唯一 ID 时,它是我自己在以前的项目中的唯一 ID。我不知道此时该怎么办。此外,我的 GoogleService-Info.plist 中的所有内容都与我的新项目相匹配。
当我在 iOS 模拟器中注销其他应用程序时,代码按预期运行。
有没有简单的解决方法?谢谢。
最佳答案
在你的模拟器中清理并重置设置!它确实有效。
关于ios - Firebase 引用的是旧项目而不是当前项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37819532/