Logout from Facebook programmatically iOS

前端 未结 6 1051
不思量自难忘°
不思量自难忘° 2020-12-29 03:53

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 pro

6条回答
  •  情书的邮戳
    2020-12-29 04:30

    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,

    fbLoginManager.loginBehavior = FBSDKLoginBehavior.web
    

    and while logout use below code

    FBSDKAccessToken.setCurrent(nil)
    FBSDKProfile.setCurrent(nil)
    FBSDKLoginManager().logOut()
    

    this works perfectly for me.

提交回复
热议问题