2

I am writing an iOS app and have implemented both Google and Facebook sign in methods.

When I log out of the app, I am taken to my log in screen.

If I close the app and open it again, I am already logged back in.

I want it to take me to my log in screen, and for some reason it remembers my as logged in. Maybe I need to clean some sort of cache?

My logout function after clicking a button:

@IBAction func LogOutButtonPressed(_ sender: Any)
    {
        // MARK - should Prompt user if to log out
        if (GIDSignIn.sharedInstance().currentUser != nil)
        {
            GIDSignIn.sharedInstance().signOut()
        }

        else if (FBSDKAccessToken.current() != nil)
        {
            let loginManager = FBSDKLoginManager()
            loginManager.logOut()
        }
        // Unwind segue to login screen

        isLoggingOut = true
    }

I looked for an answer but couldn't find any similar to what I'm looking for.

halfer
  • 19,824
  • 17
  • 99
  • 186
Ofri
  • 289
  • 5
  • 17

1 Answers1

0

You can programatically logout the user as mentioned below.

For Facebook you can logout through below line:

FBSDKLoginManager().logOut()

Remember the access token should be valid for the session.

FBSDKAccessToken.currentAccessToken()

For Google signout you can try out:

GIDSignIn.sharedInstance().signOut()

If its properly sign out you will be redirected login screen.

Rahul
  • 241
  • 1
  • 12