IOS API loginWithCompletion and logout


#1

Hi all,
i am writing an app for an iPad that will be ‘kiosk’ based. I need to (1) present the user with a login dialog, (2) allow the input of a message (3)send the message (4)logout the user.
Currently, i can do (1), (2) and (3).
I attempt to logout the user by calling the logout function, but this seems incomplete, since the next time i come into my routine, the login dialog is not displayed - it uses my original login credentials.
Can someone tell me how I can completely log out the user via Objective-C in xCode?
Thank you,
Jerry


#2

Sorry but it is hard to help you, without any further information. Which Framework are you using? How are you trying to logout the user?


#3

Sorry, i will try to be more thorough…

for login, I am using:

[[Twitter sharedInstance] logInWithCompletion:^
 (TWTRSession *session, NSError *error) {
     if (session) {
      <<< show a composer dialog >>>
      <<< send the tweet >>>
     }

for logout, I am using

[[Twitter sharedInstance] logOut];

I am including

#import <TwitterKit/TwitterKit.h>

Does that help any?
Jerry


#4

Hint: Please indent code with 4 spaces, so it is displayed properly.

It seems you are using Fabric, I am not familiar with fabric so I can’t help you much. (And the category you have chosen is wrong, as this is framework-related and not REST API related)


#5

Moved over to the Fabric category for more visibility!


#6

now that it has been moved, can anyone assist me?


#7

Actually I faced with the same issue on Fabric under Objective-C, need help of Fabric guru


#8

actually, after a LOT of reading, it seems that i DO need the REST API and OAUTH to do what i need.
now gotta open a dialog back in REST1.1 to figure out how to use https://api.twitter.com/1.1/statuses/update.json instead of https://api.twitter.com/1.1/statuses/update_with_media.json in order to be able to send a picture with a status update…
thanks all,
Jerry


#9

Hi @jdubuke and @IhorA,

The incomplete logout issue you guys are facing is actually more related to iOS persisting system accounts. TwitterKit automatically logs a user in if they were already logged in on iOS. You can workaround this behavioral in the use case of kiosk with these steps:

  1. login to Twitter in system settings > Twitter
  2. Attempt to login using your app
  3. Disallow access to Twitter accounts when the grant access dialog comes up:

This prevents TwitterKit from accessing your system accounts and every user will have to login. Hope this helps!


Logout and switch user
#10

Does anyone have a legitimate solution of how to effectively logout with Fabric? all of these threads lead to empty “solutions” that all revolve around the same answer of calling [[Twitter sharedInstance] logOut]; . Perhaps someone could show a code snippet or photo that is actually helpful


#11

Check out this stack overflow answer. It has to do with the logOut method not clearing the app’s cookies.


#12

Hello,friends I suggest one Of the best Solution for LogOut the Twitter Account using Fabric SDK for ios

- (IBAction)LogOut:(id)sender
{
    NSURL *url = [NSURL URLWithString:@"https://api.twitter.com"];
    NSArray *cookies = [[NSHTTPCookieStorage sharedHTTPCookieStorage] cookiesForURL:url];
    for (NSHTTPCookie *cookie in cookies)
    {
        [[NSHTTPCookieStorage sharedHTTPCookieStorage] deleteCookie:cookie];
    }
}

#13

thank you for the response - luckily i already figured it out!


#14

this not workin for me i am doing in Swift 3 and REST API 1.1

let store = Twitter.sharedInstance().sessionStore
if let userID = store.session()?.userID {
    store.logOutUserID(userID)
    Twitter.sharedInstance().sessionStore.logOutUserID(userID)
 }

when i retrive it. without login but they found they dont logout

let client = TWTRAPIClient.withCurrentUser()

#15

While this example is in Android, it may help as an example for you: https://twittercommunity.com/t/how-to-logout-from-twitter-account-with-android-application/79751/3?u=bonnell


#16

it doesnt work for me. i am not able to open twitter login page & it logs data for same user all the time…


#17

hey, jay

can you please check you system login for twitter application ? if it is
already loged in then first log out their and then you can check by your
application . let me know if any issue come again .

Thanks.


#18

there is no twitter application in my device & even in safari browser i am not logged in