2

i am using a Fabric SDK for logine the Twitter account ,As i am logine Do the following code in my viewDidLoad method

- (void)viewDidLoad
{
       [super viewDidLoad];

    TWTRLogInButton *loginButton = [TWTRLogInButton buttonWithLogInCompletion:^(TWTRSession *session,NSError *error){

        if (session) {
//            mysession =session;
            NSLog(@"signed in as %@", [session userName]);
        } else {
            NSLog(@"error: %@", error );
        }

    }];
    loginButton.center = self.view.center;
    [self.view addSubview:loginButton]; 
}


//and i use one UIButton for logOut ,And code for logout is as like

(IBAction)tweet:(id)sender
{
  [[Twitter sharedInstance] logOut];
}

But this code is not working for me, please suggest me a right way

Hiren kanetiya
  • 251
  • 2
  • 16
  • what do you mean by not working. If it uses your system account, you need to logout system account first I think. – air_bob Jun 17 '15 at 10:16
  • yes, i do that think frist ,but when again i pressed "login with Twitter" it can not need login credential again. and automatically login ,and console print "signed as a UserName" – Hiren kanetiya Jun 17 '15 at 10:28
  • Did you try these things http://stackoverflow.com/questions/28961014/how-to-make-user-logout-from-twitter-fabric-ios – Ashwin P Jun 17 '15 at 11:29
  • any one slove this logOut isuue ?please give me a correct way. Thanks In advance. – Hiren kanetiya Jun 18 '15 at 05:34

2 Answers2

1

this was a problem with NSCookie from Foundation framework And i slove this issues with help of below code

NSURL *url = [NSURL URLWithString:@"https://api.twitter.com"];

NSArray *cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:url];
for (NSHTTPCookie *cookie in cookies)
{
    [[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie];
}
Hiren kanetiya
  • 251
  • 2
  • 16
0

You need to set TWTRSession nil for logout. so please check Logout Method.

VD Patel
  • 286
  • 1
  • 6
  • As specified by the documentation (https://dev.twitter.com/twitter-kit/ios-reference/twitter) this deletes the local session but does not invalidate the remote session. The effect is that once I'm authenticated and then logged out, if I click the "Login" button again I'm logged-in again with the same user, effectively preventing me from switching user. – Hiren kanetiya Jun 17 '15 at 12:20