Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make User logout from twitter fabric ios

I have made a basic app using Twitter's fabric that allows user to tweet within my app and Provide Login With Twitter.Every things works a I Wanted.

How my app Works

If the user doesn't logged in to twitter my app allows him to login and if he is login then directly allows him to tweet.

Now the Big Part Comes

As I saw in many Apps I Can Remove my signed account from the app.And I am not able to get any method that help me to achieve this. I want to allow user to logout from twitter within my app whenever he/She wants.

I googled but i doesn't find anything

Here Is my Code:

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

- (IBAction)LogMeIn:(id)sender
{
[[Twitter sharedInstance] logInWithCompletion:^
 (TWTRSession *session, NSError *error) {
     if (session) {
         NSLog(@"signed in as %@", [session userName]);
         [LoginButton setTitle:@"LogOut" forState:normal];

     } else {
         NSLog(@"error: %@", [error localizedDescription]);
     }
 }];
}
like image 249
Dalvik Avatar asked Mar 10 '15 10:03

Dalvik


2 Answers

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];
}
like image 171
Hiren kanetiya Avatar answered Nov 03 '22 18:11

Hiren kanetiya


You need to use below code

[[[Twitter sharedInstance] sessionStore] logOutUserID:USERID];

Provide user id of the user you want to logout.

like image 40
Purushottam Sain Avatar answered Nov 03 '22 17:11

Purushottam Sain