Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Calling logout function of facebook ios sdk is not clearing user Credentials

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.

like image 494
Sabir Ali Avatar asked Jan 19 '23 16:01

Sabir Ali


1 Answers

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

like image 63
iProgrammer Avatar answered Jan 30 '23 11:01

iProgrammer