madLokesh
madLokesh

Reputation: 1878

Unable To Logout of Facebook using Socialize SDK

I am using Socialize SDK in lieu of Sharekit to integrate mail, twitter and facebook in my app.

I only need to post some string on the user's profile which is working fine for facebook and twitter.

Following is the workflow:

  1. User clicks on share , selects facebook/twitter.

  2. If it is for the first time user is sharing, facebook/twitter login screen pops up

  3. User Logs in and after authentication, share is successful.

  4. If user shares for the second time, facebook/twitter login screen doesn't popsup for authentication and the share is successful.

  5. If user wants to logout of facebook/twitter, he goes to the settings panel and clicks on twitter / facebook button to logout.

    [When it goes back to share after log gin out, user clicks on twitter , login screen pops up but when user clicks on facebook, a shadow box appears for few seconds and disappears and user is logged in with the previous account. ]

    How would i resolve this issue ?

I have tried using

[SocializeThirdPartyFacebook removeLocalCredentials] and also 

[SZFacebookUtils unlink]; 

how should i go about it

I tried Clearing all the cache and cookies as well but still the same result

 NSHTTPCookieStorage* cookies =   [NSHTTPCookieStorage sharedHTTPCookieStorage];
        NSArray* facebookCookies = [cookies cookiesForURL:
                                    [NSURL URLWithString:@"http://login.facebook.com"]];

        for (NSHTTPCookie* cookie in facebookCookies) {

            NSLog(@"In For");
            [cookies deleteCookie:cookie];

            NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
            [defaults removeObjectForKey:kSocializeFacebookAuthAppId];
            [defaults removeObjectForKey:kSocializeFacebookAuthLocalAppId];
            [defaults removeObjectForKey:kSocializeFacebookStringForAPI];
            [defaults removeObjectForKey:kSocializeConsumerKey];
            [defaults removeObjectForKey:kSocializeConsumerSecret];

Upvotes: 0

Views: 698

Answers (2)

user1503659
user1503659

Reputation:

Facebook and twitter SDK save access token in cookies.

So you have to clear all cache and cookies when you are trying to use logging mechanism in your code.

Upvotes: 2

madLokesh
madLokesh

Reputation: 1878

I solved it:

1.In the advance settings of the app on facebook, i enabled native/desktop app

2.Disabled SSO in basic settings

3.Added de-auth callback url in advance settings

4.Added the following piece of code:

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];
        }
    }

Upvotes: 0

Related Questions