简体   繁体   English

如何通过swift中的谷歌帐户检查用户是否已在firebase中注册

[英]how to check if user has already signed up or not in firebase via google account in swift

I want to do an action for user that login for the first time (signed up) using google account and another action if the user has already login before. 我想为使用谷歌帐户首次登录 (已注册)的用户执行操作,如果用户之前已登录,则执行其他操作。

if some user has been and still logged in using their Google account, we can use this lines of code 如果某个用户已经并且仍然使用他们的Google帐户登录,我们可以使用这行代码

Auth.auth().addStateDidChangeListener { (auth, user) in
    if user == nil {
        self.goToLoginVC()
    }
}

but how can I differentiate if a user login for the first time (signed up) or not ? 但如果用户第一次登录(注册),我怎么能区分? is there any particular method to accomplish this? 有什么特别的方法来实现这个目标吗? Thanks 谢谢

You can use UserDefault to check the same. 您可以使用UserDefault来检查相同内容。 Just maintain the flag to check 只需保持要检查的标志

like 喜欢

    GIDSignIn.sharedInstance().signInSilently()


   Auth.auth().addStateDidChangeListener { (auth, user) in
        if user != nil {
             if UserDefaults.standard.string(forKey: "uid") != nil && Auth.auth().currentUser != nil {
              //User was already logged in 
               }

             UserDefaults.standard.setValue(user?.uid, forKeyPath: "uid")

            self.performSegue(withIdentifier: "CurrentlyLoggedIn", sender: nil)

        }
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何检查用户是否已登录Swift中的Google帐户? - How to check if a user has logged in to a Google account in Swift? 如何检查是否已使用 Google/Facebook 帐户在 Firebase Auth 上创建帐户 - How to check if Google/Facebook account has already been used to create account on Firebase Auth 仅通过电子邮件检查用户是否已经有一个帐户 - Check if user already has an account just by email 用户在iPhone应用程序中输入google +帐户凭据后,如何保持用户登录? - How to keep user signed in once user has entered google+ account credentials in iphone app? Swift:如何在AppDelegate中签入用户是否已经登录 - Swift: How to check in AppDelegate if user is already logged in FBSDK检查用户是否已经授权应用程序Swift - FBSDK check if user has already authorised app Swift Firebase 身份验证:如何知道 Google 或 Facebook 提供商的帐户是否已经存在? - Firebase Authentication: How to know if account with Google or Facebook provider already exist? Firebase检查用户是否已经存在 - Firebase Check if user already exists Firebase用户登录了Swift / xcode / ios Keep - Firebase User signed in for Swift/xcode/ios Keep App Delegate 或初始视图控制器,检查用户是否通过 Firebase 登录 iOS 应用程序? - App Delegate or initial view controller, to check if a user is signed in via Firebase for an iOS app?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM