如何从Facebook注销 [英] How to logout from facebook

查看:852
本文介绍了如何从Facebook注销的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经从developer.Facebook.com下载了Facebook的最新sdk,并在代码中实现了该sdk.现在,当我第一次发布到Facebook时,它会使用Safari登录到Facebook,并在成功登录后将其发布到Facebook,此后它不要求登录,但我想再次要求登录.因此,我编写了以下注销功能,但对我不起作用.有人有什么主意吗?请帮助我.

Hi, I have download the latest sdk of Facebook from developer.Facebook.com and i implemented the sdk in my code. Now when i post to Facebook the first time it goes to Safari for login to Facebook and after successful login it posts to Facebook and after that it doesn't ask for login but i want to ask for login again. So i wrote the following logout function but it didn't work for me. Does any one have any idea? please help me.

NSLog(@"Logged out of facebook");
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];
        }
}

推荐答案

要从Facebook中注销,您只需要执行以下操作:

To logout from Facebook you just have to do:

[FBSession.activeSession closeAndClearTokenInformation];

编辑1 :这将关闭内存中会话.如果登录是通过Safari进行的,则该会话仍在Safari中打开,并且恐怕您与此无关.

EDIT 1: This will close the in-memory session. If the login is made through Safari, it's in Safari where the session is still open, and I'm afraid you've got nothing to do with that.

要确认这一点,请尝试打开Safari应用程序(独立)并在使用您的应用程序登录后输入facebook.com.会话仍将打开.

To confirm that, try to open the Safari app (standalone) and enter facebook.com after login in with your application. The session will be still open.

这篇关于如何从Facebook注销的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆