Unable To Logout of Facebook using Socialize SDK

我怕爱的太早我们不能终老 提交于 2019-12-10 12:15:16

问题


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

回答1:


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.




回答2:


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


来源:https://stackoverflow.com/questions/12280436/unable-to-logout-of-facebook-using-socialize-sdk

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!