Search code examples
iosswiftgoogle-signin

How to check if a user has logged in to a Google account in Swift?


I am developing a small iOS application on Swift, and I use google sign in sdk to sign in. When a user clicks on the enter button, he should transfer to another view if successful, I don’t know how to check whether the user entered or canceled the input, thanks in advance.


Solution

  • Please try below code,

    if(GIDSignIn.sharedInstance.currentUser != nil) {
        //logged in
    } else {
        //not logged in
    }
    

    Hope this works for you!