本文介绍了如何在 iOS 应用程序中使用 Fabric 注销 Twitter的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

共享实例注销不起作用.我知道这对开发人员来说是一个大问题.有没有人有办法解决吗?谢谢

Shared Instance Logout does not work. I know this is a big problem for developers. Does anyone have a solution? Thanks

推荐答案

我在大约 3 个月前遇到了这个问题,现在刚刚找到了解决方案.显然,清除 cookie 确实可以清除 Twitter 为以前登录的用户存储的信息.下面的代码对我有用:

I ran into this issue about 3 months ago and have just now found a solution to this. Apparently clearing cookies does in fact get rid of Twitter's stored information for previously logged in users. The code below is working for me:

!警告!确保在您首次登录时禁止 Twitter 访问您在设备上的帐户.这会导致 Twitter 每次都强制用户登录,而不是直接查看保存在设备上的 Twitter 帐户.希望这会有所帮助!

!WARNING! Make sure when you first log in that you Disallow Twitter from accessing your accounts on the device. This causes Twitter to force login the user each time instead of looking straight at your Twitter account saved to your device. Hope this helps!

- (IBAction)twitterLogout:(id)sender {
    [[Twitter sharedInstance] logOut];
    [self.view insertSubview:_logoutTwitter atIndex:16];


    NSHTTPCookie *cookie;
    NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
    for (cookie in [storage cookies])
    {
        NSString* domainName = [cookie domain];
        NSRange domainRange = [domainName rangeOfString:@"Twitter"];
        if(domainRange.length > 0)
        {
            [storage deleteCookie:cookie];
        }
    }

    NSURL *url = [NSURL URLWithString:@"https://api.twitter.com"];
    NSArray *cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:url];
    for (NSHTTPCookie *cookie in cookies)
    {
        [[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie];
    }

}

这篇关于如何在 iOS 应用程序中使用 Fabric 注销 Twitter的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-26 19:59