HTML5   发布时间:2022-04-27  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了ios – Swift:使用Firebase自动登录用户大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我想自动登录用户,如果他已经签名并且只是前往主视图但代码运行了两次,你可以看到转换而不是刚刚显示的视图.我如何解决它?

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自动登录用户全部内容,希望文章能够帮你解决ios – Swift:使用Firebase自动登录用户所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。