2

This is what I do in my controller:

let button = FBSDKLoginButton(frame: CGRectMake(100, 100, 300, 50))
button.readPermissions = ["public_profile", "user_friends"]
view.addSubview(button)

After viewDidLoad I click that button, write my login and password and since then I always have such view:

enter image description here

How to log out from that? It appears always, even I remove the app from Simulator. What is wrong?

Andrew
  • 227,796
  • 193
  • 515
  • 708
Bartłomiej Semańczyk
  • 59,234
  • 49
  • 233
  • 358

2 Answers2

0


1> GOTO the safari app and open facebook.com
2> Open your account preference.
3> log out form your account.

OR


1> GOTO "Setting".
2> Click "Safari".
3> Click "Clear History and Website Data".

Also you remove app Permission from facebook than go to Profile-->APP-->find your application name -->remove data.

Nimantha
  • 6,405
  • 6
  • 28
  • 69
Ilesh P
  • 3,940
  • 1
  • 24
  • 49
  • @BartłomiejSemańczyk please see this link http://stackoverflow.com/questions/6226950/facebook-ios-sdk-logout-question – Ilesh P Sep 14 '15 at 11:49
  • It is not the question about `Facebook-ios-sdk` because it is DEPRECATED. The question is about `FBSDKLoginKit` so simply it is not helpful. – Bartłomiej Semańczyk Sep 14 '15 at 11:51
  • @BartłomiejSemańczyk it is not possible to clear the cookies from our app to safari programmatically. see the discussion .http://stackoverflow.com/questions/30207893/facebook-does-not-logout-properly-in-ios-app-cannot-switch-users – Ilesh P Sep 14 '15 at 11:57
  • 1
    I suppose you do not understand sth. `FBSDKLoginButton`'s delegate has a method: `loginButtonDidLogOut()`. Since there is such method, there must be a way to call this. How to do this? IN other words how to logout in code? – Bartłomiej Semańczyk Sep 14 '15 at 12:07
  • @BartłomiejSemańczyk , FBSDKLoginManager *loginManager = [[FBSDKLoginManager alloc] init]; [loginManager logOut]; or [FBSDKAccessToken setCurrentAccessToken:nil]; – Ilesh P Sep 14 '15 at 12:13
  • It doesn't make me able to login again with `login` and `password`. I begin to doubt:) – Bartłomiej Semańczyk Sep 14 '15 at 12:17
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/89585/discussion-between-ilesh-and-bartlomiej-semanczyk). – Ilesh P Sep 14 '15 at 12:18
0

Below two methods must be implemented in AppDelegate:

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
    return FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
}

func application(application: UIApplication, openURL url: NSURL, sourceApplication: String?, annotation: AnyObject) -> Bool {
    return FBSDKApplicationDelegate.sharedInstance().application(application, openURL: url, sourceApplication: sourceApplication, annotation: annotation)
}

And then once you click Log In with Facebook and then OK, your FBSDKLoginButton will change to:

enter image description here

Once you tap this, you are able to logout with following dialog:

enter image description here

Bartłomiej Semańczyk
  • 59,234
  • 49
  • 233
  • 358