因此,我正在开发一款新应用,并且我正在使用Firebase来管理用户登录等所有后端内容,我为用户创建了登录/注册屏幕他们加载应用程序。我想要做的是加载HomeScreenVC,如果用户已经登录,如果用户不是,那么他们会被引导到登录/注册vc。Firebase + Swift:绕过用户登录屏幕
如果用户已经是currentUser,但它的工作原理,我有种工作,但我遇到的问题是,如果用户从未加载应用程序然后崩溃,因为它无法检测currentUser 。
我的代码我在AppDelegate的是:
var window: UIWindow?
var storyboard: UIStoryboard?
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.
FIRApp.configure()
self.storyboard = UIStoryboard(name: "Main", bundle: NSBundle.mainBundle())
let currentUser = FIRAuth.auth()?.currentUser!
if currentUser != nil
{
self.window?.rootViewController = self.storyboard?.instantiateViewControllerWithIdentifier("tabVC")
}
else
{
self.window?.rootViewController = self.storyboard?.instantiateViewControllerWithIdentifier("loginScreen")
}
return true
}
这是错误我得到:here
任何帮助将是巨大的!我使用的是Firebase和Swift 2的最新版本。
工作!非常感谢!!!! – Konsy