Facebook Logout Is Not Working in New Sdk V.4.1.0 in iOS

Facebook Logout is not working in new SDK V.4.1.0 in ios?

I am also stuck in the same place. However surfing i came to following conclusion.

First lets know the meaning of SingleSignOn:

Single sign-on (SSO) is a property of access control of multiple related, but independent software systems. With this property a user logs in once and gains access to all systems without being prompted to log in again at each of them.

i think theres some point.Why, we are not asked again to login although we have logged out? Its because on simulator the credential has been saved on safari(on the first time using facebook login, your app opens safari or facebook app if installed).

The information that allows you to see the 'you have already authorized...' message lies with Facebook.In order to revoke permissions from your app, you will need to touch the Graph API. FB docs, in the 'Delete' section of https://developers.facebook.com/docs/reference/api/user/

Revoking Login

You can also let people completely de-authorize an app, or revoke login, by making a call to this Graph API endpoint:
DELETE /{user-id}/permissions

e.g in swift:

 let deletepermission = FBSDKGraphRequest(graphPath: "me/permissions/", parameters: nil, HTTPMethod: "DELETE")
deletepermission.startWithCompletionHandler({(connection,result,error)-> Void in
println("the delete permission is \(result)")

})

But in order to logout from the app completely so that user will be prompted to re-enter credentials,see below:

You have to logout from facebook app , then only you are truly logged out and then only the app again asks for credentials.It's because you are not logged anywhere on the phone.So,SSO rule doesnot apply here. If you are logging out only from your app (not the fb one) you will get logged because of logged in from safari in your case.Thats why, you will get the same message showing you are already authorized for this app.

Try testing on simulator, while you insert the credentials for the first time then safari opens and the credentials you enter saves in safari. So,next time when you logout and login app it doesnot ask for credentials.Because safari provides it(or facebook app if you have entered your credential there)

Now you open safari and open facebook. You see facebook has already open and the info it takes from the safari automatically or if you have facebook app installed then from there. So logout from safari and reopen your app and logout from the app.Then your app will ask again credentials.

Login Logout issue with facebook iOS sdk

FBSession openWithBehavior:completionHandler: can be used..

FBSession *fbSession = [[FBSession alloc] initWithPermissions:[NSArray arrayWithObjects:@"email",@"publish_actions",@"publish_stream", nil]];
[fbSession openWithBehavior:FBSessionLoginBehaviorForcingWebView completionHandler:^(FBSession *session,FBSessionState state, NSError *error){
[FBSession setActiveSession:fbSession]; // Retain the Active Session.
}];

For Logging out, Ans by Ellen S.. worked fine for iOS .

Clear token in Facebook SDK V4.0.1 for iOS

If you take a look at the changelog for the FB SDK it states that FBSession and FBAccessTokenData are replaced by FBSDKLoginManager.

If you then take a look at FBSDKLoginManager, reference, it states that

FBSDKLoginManager provides methods for logging the user in and out.

Via this method you should be able to log the user out. Does the login button not automatically change to a logout button when the user is logged in?

Swift iOS App Facebook SDK 4.0 on login/logout methods not executing

Assign delegate to your FBSDKLoginButton.

class ViewController: UIViewController,FBSDKLoginButtonDelegate {

override func viewDidLoad() {
super.viewDidLoad()

var loginButton = FBSDKLoginButton()
loginButton.delegate = self
loginButton.frame = CGRectMake(100, 100, 150, 40)
self.view.addSubview(loginButton)
}

Once user is logged in the following delegate method is called.

func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {

println("User Logged In")
}

Once user is logged out the following delegate method is called.

func loginButtonDidLogOut(loginButton: FBSDKLoginButton!) {

println("User Logged Out")
}

Facebook logout not working properly through the Facebook Connect iPhone API

Are you using FB mobile Login Dialog? In Facebook.m, add the following code to remove cookies at m.facebook.com domain.

- (void)invalidateSession {

...
NSArray* facebookMCookies = [cookies cookiesForURL:
[NSURL URLWithString:@"https://m.facebook.com"]];

for (NSHTTPCookie* cookie in facebookMCookies) {
[cookies deleteCookie:cookie];
}

...
}


Related Topics



Leave a reply



Submit