While implementing facebook SSO, calling logout function of facebook ios sdk is not clearing user Credentials and it does not ask to login next time.
I Used Graph Api.....
- (IBAction)loginButtonPressed:(id)sender {
NSString *client_id = @"dsfgdgfgfgdfgvdfg";
//alloc and initalize our FbGraph instance
self.fbGraph = [[FbGraph alloc] initWithFbClientID:client_id];
//begin the authentication process.....
[fbGraph authenticateUserWithCallbackObject:self andSelector:@selector(fbGraphCallback:)
andExtendedPermissions:@"user_photos,user_videos,publish_stream,offline_access,user_checkins,friends_checkins"];
}
- (void)logOutButtonPressed {
NSLog(@"logout");
fbGraph.accessToken = nil;
NSHTTPCookie *cookie;
NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
for (cookie in [storage cookies])
{
NSString* domainName = [cookie domain];
NSRange domainRange = [domainName rangeOfString:@"facebook"];
if(domainRange.length > 0)
{
[storage deleteCookie:cookie];
}
}
[self loginButtonPressed:nil];
}
And This code is WORKING FINE..TRY THIS
I've experienced the same, however I think it's not a bug, confusing though.
Facebook places a cookie in the mobile safari which refers to a valid session or maybe an access token. If you logout with the Facebook lib it clears the access token and all cookies of the webview used not in mobile safari. Actually you can't do that by code. Now if you come back and mobile safari opens up, there is still a valid session and you are logged in again without entering credentials.
You may file a bug to ask if Facebook can invalidate the access token server side.
来源:https://stackoverflow.com/questions/6068205/calling-logout-function-of-facebook-ios-sdk-is-not-clearing-user-credentials