gpt4 book ai didi

swift - “自动登录”不再起作用

转载 作者:行者123 更新时间:2023-11-30 11:20:29 25 4
gpt4 key购买 nike

我的应用使用了 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 都是最新的)

为什么它不再工作了?

最佳答案

您的 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

关于swift - “自动登录”不再起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51322716/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com