“自动登录”不再起作用

时间:2018-07-13 10:07:42

标签: swift firebase firebase-authentication

我正在为我的应用程序使用一个Firebase项目,用户必须在该项目上创建一个帐户来访问该应用程序的内容。

为了避免用户每次启动该应用程序都必须登录,我将其放置在(位于AppDelegate中):

if Auth.auth().currentUser != nil {
        self.window = UIWindow(frame: UIScreen.main.bounds)
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let viewController = storyboard.instantiateViewController(withIdentifier: "tabBar")
        self.window?.rootViewController = viewController
        self.window?.makeKeyAndVisible()
    } else {
        self.window = UIWindow(frame: UIScreen.main.bounds)
        let storyboard = UIStoryboard(name: "Main", bundle: nil)
        let viewController = storyboard.instantiateViewController(withIdentifier: "InscriptionViewController")
        self.window?.rootViewController = viewController
        self.window?.makeKeyAndVisible()
    }

这段代码在过去几个月中确实有效,但是现在却不行(我所有的pod都是最新的)

为什么它不再起作用了?

1 个答案:

答案 0 :(得分:0)

您的AppDelegate应该看起来像这样。

import UIKit
import Firebase

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

  var window: UIWindow?

  func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

  FirebaseApp.configure()

  if Auth.auth().currentUser != nil {
  //your code 
  }

  }
}

尝试下载google-info.plist enter image description here