如何使用iOS中的Fabric框架从我的应用程序中从twitter注销

时间:2015-06-04 05:15:09

标签: ios twitter

在我的iOS应用程序中,我使用结构框架 TWTRComposer ”整合了Twitter登录。 首次登录并在Twitter上发布twit时工作正常。 但我无法在我的应用程序中从twitter注销。 我第二次尝试登录twitterlogin视图控制器无法打开。 所以任何人都可以使用 TWTRComposer

从我的应用程序中成功解析登录和注销

4 个答案:

答案 0 :(得分:2)

[Twitter sharedInstance]对象有两种注销方法:logOut和logOutGuest。

以下是文档的链接:Twitter object iOS reference

仅供参考,您可以使用会话参数(如下所示)检查用户是否已登录

[[Twitter sharedInstance] session]

如果会话为零,则表示他们未登录。

如果上面的东西不起作用,请尝试下面的事情,可能饼干仍然存在。

NSHTTPCookieStorage *cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
    for (NSHTTPCookie *each in cookieStorage.cookies) {
       // put a check here to clear cookie url which starts with twitter and then delete it
         [cookieStorage deleteCookie:each];
    }

答案 1 :(得分:1)

[[Twitter sharedInstance] logOut]

[[Twitter sharedInstance] logOutGuest]

不起作用,因为根据文档:

  

从此应用删除本地Twitter用户会话。这不会   删除系统Twitter帐户也不发送网络请求   使会话无效。

另外,您需要使oauth返回的令牌无效。您可以从twitter's文档获得帮助。使用此REST Web服务以使令牌无效。将access_token传递给帖子请求。

根据链接,

  

允许已注册的应用程序撤销已颁发的OAuth 2承载   令牌通过提供其客户端凭据。一旦承载令牌有   已失效,新创作尝试将产生不同的持有者   将不再允许令牌和无效令牌的使用。

希望它有所帮助!

答案 2 :(得分:0)

使用此代码:

  [[Twitter sharedInstance] logOut];

答案 3 :(得分:0)

删除cookie - 没有帮助。

我为relogin创建了自己的流程:

我需要用户电子邮件才能进一步登录,所以只有WebBasedLogin

// Get first twitter acc (check if it exists etc...)
.....

// This method will be used if user the same
TWTRLoginMethod loginMethod = TWTRLoginMethodSystemAccounts;

// Check if it is the Previous twitter user (whom was stored in userDefaults)
if (![[STLUserDataManager lastTwitterUser] isEqualToString:[firstTwitterAccount username]])
{
// if user is new - ForceLogin
    loginMethod = TWTRLoginMethodWebBasedForceLogin;
}

// inside completion
{
 ...
// Store userName in userDefaults
[STLUserDataManager storeTwitterUser:[firstTwitterAccount username]];
}
相关问题