2013-07-06 18 views
8
FHSTwitterEngine *engine = [FHSTwitterEngine sharedEngine]; 
[engine clearAccessToken]; 

我試過上面的代碼,但是當我嘗試再次登錄時,textfields沒有在presentModalViewController中顯示,它顯示了Authorize app按鈕。如何獲得完全註銷從FHSTwitterEngine在Twitter上REST API v1.1的?

還有另一種方法,[engine clearConsumer];導致Select and Copy the PINpresentModalViewController

回答

12

相信餅乾仍然存在,這與大多數iOS上的Twitter的API的主要問題。

這是你可以檢查所有的cookies,把支票之間只清除嘰嘰喳喳你在哪裏在twitter上進行註銷操作餅乾:

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

它的工作!下面的代碼內用於 如果([[每valueForKey:@ 「域」] isEqualToString:@ 「twitter.com。」]){ [cookieStorage deleteCookie:每個]; } 謝謝哥們.. –

+0

不錯,很高興它的工作適合你。 :) –

+0

感謝它爲我工作.. –

4

添加以下方法FHSTwitterEngine.hm文件。

- (void)logout 
{ 
    NSLog(@"Logged out from twitter"); 

    //These is FHSTwitterEngine class method which clears accesstoken 
    [self clearAccessToken]; 

    //clear cache of twitter from NSHTTPCookieStorage 
    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]; 
    } 
    } 
} 

編輯:使用這些方法,像這樣:

[[FHSTwitterEngine sharedEngine] logout];