I am trying to logout from Facebook programmatically without using FBSDKLoginButton
i had search how could I do
i found this answer Can we logout facebook programatically
but the problem is the FBSession
is deprecated in new iOS FBSDK version
my question is
Is there any way to clear the fb session in the new iOS FBSDK version? if there any way to logout from Facebook programmatically?
or how could I call the logout action from FBSDKLoginButton
Thanking in advance :)
Swift 3 and Swift 4:
You have two methods to logout. First, as suggested by Inder Kumar Rathore
Second is by setting the currentAccessToken to nil
@cookiemonsta hope second method works for you.
FBSDKLoginManager
is your need, it haslogOut
method but you might have to use your custom logine.g.
Swift version:
You can use
FBSDKLoginManager
even if you logged in withFBSDKLoginButton
.For Swift 3 and 4
I would like to use the code mentioned over here, How to logout user using Facebook authentication using Swift and iOS?
where HardikDG mentioned a good answer for logout. what you need to do is add below line before the login happen,
and while logout use below code
this works perfectly for me.