ios - Logout of Active Twitter Session Using Fabric -


i have read through forums , suggestions how logout of twitter in xcode ios using fabric, can't logout method call , logout user current session. here current code login view controller:

- (ibaction)testt:(id)sender { [[twitter sharedinstance] loginwithcompletion:^  (twtrsession *session, nserror *error) {      if (session != nil) {          nslog(@"signed in %@", [session username]);      } else {          nslog(@"error: %@", [error localizeddescription]);      }  }]; }  - (ibaction)logout:(id)sender { [self logout]; }  - (void)logout{ [[twitter sharedinstance] logout]; } 

i have imported , have login functionality working fabric tutorial.

i can't button made using logout action logout user current twitter session. have tried clear cookies see if wipe twitter session memory , reset - nothing. if me out appreciate - thanks!

fyi: please not suggest only [[twitter sharedinstance] logout]; . method not asking itself. if can tell me how logout using method along rest of procedure fine.

after long extensive series of methods, clearing of cookies, data, think of, discovered quite simple.

the easiest way sign out , clear previous user session follows:

  1. go settings
  2. go twitter , disallow twitter access app (it should appear here)
  3. go app , call following method:

    - (void)twitterlogout:(id)sender {     nsuserdefaults *twittersession = [nsuserdefaults standarduserdefaults];     [twittersession setobject:0 forkey:@"twittersession"];     [twittersession synchronize];      nslog(@"twitter session = %@", twittersession);      [[twitter sharedinstance] logout];     [self.view insertsubview:_logouttwitter atindex:16];       nshttpcookie *cookie;      nshttpcookiestorage *storage = [nshttpcookiestorage sharedhttpcookiestorage];     (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];     (nshttpcookie *cookie in cookies)     {         [[nshttpcookiestorage sharedhttpcookiestorage] deletecookie:cookie];     }   } 

there quite lot in method, , honest of extraneous , not needed, needs can mess around should , shouldn't stay. either way helps people - helped me!


Comments