gpt4 book ai didi

ios - Swift:使用 Firebase 自动登录用户

转载 作者:IT王子 更新时间:2023-10-29 05:41:37 24 4
gpt4 key购买 nike

如果用户已经签名,我想自动登录他,然后直接转到主视图,但代码运行了两次,您可以看到转换,而不是刚刚显示的 View 。我该如何解决?

AppDelegate.swift

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// Override point for customization after application launch.slideMenuController
FIRApp.configure()
FIRAuth.auth()?.addAuthStateDidChangeListener {
auth, user in
if user != nil {
// User is signed in.
print("Automatic Sign In: \(user?.email)")

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let initialViewController = storyboard.instantiateViewControllerWithIdentifier("EmployeeRevealViewController")
self.window!.rootViewController = initialViewController

} else {
// No user is signed in.
}
}

return true
}

日志

2016-06-06 01:00:55.585 Untitled[13009:6258910] Configuring the default app.
2016-06-06 01:00:55.657 Untitled[13009:] <FIRAnalytics/INFO> Firebase Analytics v.3200000 started
2016-06-06 01:00:55.666 Untitled[13009:] <FIRAnalytics/INFO> To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled
2016-06-06 01:00:55.714 Untitled[13009:6258910] Firebase Crash Reporting: Successfully enabled
2016-06-06 01:00:55.739: <FIRInstanceID/WARNING> FIRInstanceID AppDelegate proxy enabled, will swizzle app delegate remote notification handlers. To disable add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO
2016-06-06 01:00:55.739: <FIRInstanceID/WARNING> Failed to fetch APNS token Error Domain=com.firebase.iid Code=1001 "(null)"
2016-06-06 01:00:55.760: <FIRMessaging/INFO> FIRMessaging library version 1.1.0
2016-06-06 01:00:55.781: <FIRMessaging/WARNING> FIRMessaging AppDelegate proxy enabled, will swizzle app delegate remote notification receiver handlers. Add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO
2016-06-06 01:00:55.788 Untitled[13009:] <FIRAnalytics/INFO> Successfully created Firebase Analytics App Delegate Proxy automatically. To disable the proxy, set the flag FirebaseAppDelegateProxyEnabled to NO in the Info.plist
Automatic Sign In: Optional("mohamed.mohd@hotmail.com")
2016-06-06 01:00:56.759: <FIRInstanceID/WARNING> APNS Environment in profile: development
Automatic Sign In: Optional("mohamed.mohd@hotmail.com")
2016-06-06 01:00:57.811 Untitled[13009:] <FIRAnalytics/INFO> Firebase Analytics enabled

最佳答案

尝试:

if let alreadySignedIn = FIRAuth.auth()?.currentUser {
// segue to main view controller
} else {
// sign in
}

关于ios - Swift:使用 Firebase 自动登录用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37649879/

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